Form Label
A text component that provides information about another component.
import { FormLabel, type FormLabelProps } from '~/components/ui/form-label'
export const Demo = (props: FormLabelProps) => {
return <FormLabel {...props}>I'm a label</FormLabel>
}
import { FormLabel, type FormLabelProps } from '~/components/ui/form-label'
export const Demo = (props: FormLabelProps) => {
return <FormLabel {...props}>I'm a label</FormLabel>
}
Usage
import { FormLabel } from '~/components/ui/form-label'
Installation
npx @park-ui/cli components add form-label
1
Add Styled Primitive
Copy the code snippet below into ~/components/ui/styled/form-label.tsx
import { ark } from '@ark-ui/react/factory'
import { styled } from 'styled-system/jsx'
import { formLabel } from 'styled-system/recipes'
import type { ComponentProps } from 'styled-system/types'
export type FormLabelProps = ComponentProps<typeof FormLabel>
export const FormLabel = styled(ark.label, formLabel)
import { ark } from '@ark-ui/solid'
import type { ComponentProps } from 'solid-js'
import { styled } from 'styled-system/jsx'
import { formLabel } from 'styled-system/recipes'
export type FormLabelProps = ComponentProps<typeof FormLabel>
export const FormLabel = styled(ark.label, formLabel)
No snippet found
2
Add Re-Export
To improve the developer experience, re-export the styled primitives in~/components/ui/form-label.tsx
.
export { FormLabel, type FormLabelProps } from './styled/form-label'
export { FormLabel, type FormLabelProps } from './styled/form-label'
3
Integrate Recipe
If you're not using @park-ui/preset
, add the following recipe to yourpanda.config.ts
:
import { defineRecipe } from '@pandacss/dev'
export const formLabel = defineRecipe({
className: 'formLabel',
base: {
color: 'fg.default',
fontWeight: 'medium',
},
defaultVariants: {
size: 'md',
},
variants: {
size: {
sm: {
textStyle: 'sm',
},
md: {
textStyle: 'sm',
},
lg: {
textStyle: 'sm',
},
xl: {
textStyle: 'md',
},
},
},
})