🔥 Meet Our New Project: t0ggles - Your Ultimate Project Management Tool!

Login Screen React Component

Login Screen React component represents Login Screen component.

Login Screen Components

There are following components included:

Login Screen Properties

PropTypeDefaultDescription
<LoginScreen> properties
openedbooleanfalseAllows to open/close Login Screen and set its initial state
animatebooleanWhether the modal should be opened/closed with animation or not
containerElHTMLElement
string
Element to mount modal to (default to app root element)

Login Screen Events

EventDescription
<LoginScreen> events
loginScreenOpenEvent will be triggered when Login Screen starts its opening animation
loginScreenOpenedEvent will be triggered after Login Screen completes its opening animation
loginScreenCloseEvent will be triggered when Login Screen starts its closing animation
loginScreenClosedEvent will be triggered after Login Screen completes its closing animation

Open And Close Login Screen

In addition to Login Screen open()/close() methods, you can open and close it:

Examples

login-screen.jsx
import React, { useState } from 'react';
import {
  Navbar,
  Page,
  LoginScreen,
  ListInput,
  List,
  ListItem,
  Block,
  Button,
  LoginScreenTitle,
  BlockFooter,
  ListButton,
  f7,
} from 'framework7-react';

export default () => {
  const [loginScreenOpened, setLoginScreenOpened] = useState('');
  const [username, setUsername] = useState('');
  const [password, setPassword] = useState('');

  const signIn = () => {
    f7.dialog.alert(`Username: ${username}<br>Password: ${password}`, () => {
      f7.loginScreen.close();
    });
  };

  return (
    <Page>
      <Navbar title="Login Screen"></Navbar>
      <Block>
        <p>
          Framework7 comes with ready to use Login Screen layout. It could be used inside of page or
          inside of popup (Embedded) or as a standalone overlay:
        </p>
      </Block>

      {/* example-hidden-start */}
      <List strong insetMd outlineIos>
        <ListItem link="/login-screen-page/" title="As Separate Page"></ListItem>
      </List>
      {/* example-hidden-end */}

      <Block>
        <Button raised large fill loginScreenOpen=".demo-login-screen">
          As Overlay
        </Button>
      </Block>

      <Block>
        <Button
          raised
          large
          fill
          onClick={() => {
            setLoginScreenOpened(true);
          }}
        >
          Open Via Prop Change
        </Button>
      </Block>

      <LoginScreen
        className="demo-login-screen"
        opened={loginScreenOpened}
        onLoginScreenClosed={() => {
          setLoginScreenOpened(false);
        }}
      >
        <Page loginScreen>
          <LoginScreenTitle>Framework7</LoginScreenTitle>
          <List form>
            <ListInput
              label="Username"
              type="text"
              placeholder="Your username"
              value={username}
              onInput={(e) => {
                setUsername(e.target.value);
              }}
            />
            <ListInput
              label="Password"
              type="password"
              placeholder="Your password"
              value={password}
              onInput={(e) => {
                setPassword(e.target.value);
              }}
            />
          </List>
          <List inset>
            <ListButton onClick={signIn}>Sign In</ListButton>
            <BlockFooter>
              Some text about login information.
              <br />
              Lorem ipsum dolor sit amet, consectetur adipiscing elit.
            </BlockFooter>
          </List>
        </Page>
      </LoginScreen>
    </Page>
  );
};

Separate Login Screen Page

login-screen-page.jsx
import React, { useState } from 'react';
import {
  Page,
  LoginScreenTitle,
  List,
  ListInput,
  ListButton,
  BlockFooter,
  f7,
} from 'framework7-react';

export default ({ f7router }) => {
  const [username, setUsername] = useState('');
  const [password, setPassword] = useState('');
  const signIn = () => {
    f7.dialog.alert(`Username: ${username}<br>Password: ${password}`, () => {
      f7router.back();
    });
  };
  return (
    <Page noToolbar noNavbar noSwipeback loginScreen>
      <LoginScreenTitle>Framework7</LoginScreenTitle>
      <List form>
        <ListInput
          label="Username"
          type="text"
          placeholder="Your username"
          value={username}
          onInput={(e) => {
            setUsername(e.target.value);
          }}
        />
        <ListInput
          label="Password"
          type="password"
          placeholder="Your password"
          value={password}
          onInput={(e) => {
            setPassword(e.target.value);
          }}
        />
      </List>
      <List inset>
        <ListButton onClick={signIn}>Sign In</ListButton>
        <BlockFooter>
          Some text about login information.
          <br />
          Lorem ipsum dolor sit amet, consectetur adipiscing elit.
        </BlockFooter>
      </List>
    </Page>
  );
};