FormContainer
FormContainer provides a styled wrapper for form sections with theme support and error states.
Featuresβ
- π¨ Light/dark themes
- β Error state styling
- π Customizable spacing
- π― No padding option
Basic Usageβ
import { FormContainer } from '@tansuk/rott-ui';
<FormContainer>
<Input name="email" type="email" />
<Input name="password" type="password" />
</FormContainer>
With Themeβ
<FormContainer theme="dark">
<Input name="email" type="email" theme="dark" />
<Input name="password" type="password" theme="dark" />
</FormContainer>
Error Stateβ
<FormContainer hasError>
<Input name="email" type="email" errorMessage="Invalid email" touched />
</FormContainer>
Propsβ
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | - | Form content |
hasError | boolean | false | Error state |
theme | 'light' | 'dark' | 'light' | Theme |
marginBottom | number | - | Bottom margin |
marginTop | number | - | Top margin |
noPadding | boolean | false | Remove padding |
Examplesβ
Login Formβ
<FormContainer theme="light">
<Input
name="email"
type="email"
label="Email"
marginBottom={16}
/>
<Input
name="password"
type="password"
label="Password"
marginBottom={24}
/>
<Button variant="primary" size="full">
Sign In
</Button>
</FormContainer>
Payment Formβ
<FormContainer hasError={hasErrors}>
<Input name="cardNumber" type="creditCard" label="Card Number" />
<Item row>
<Input name="expiry" type="expireDate" label="Expiry" flex={1} marginRight={8} />
<Input name="cvc" type="cvc" label="CVC" flex={1} marginLeft={8} />
</Item>
<Button variant="primary" size="full" marginTop={24}>
Pay Now
</Button>
</FormContainer>