p = mk_previewer()Components
FastHTML wrappers for Zendesk Garden CSS components
Anchors
The c-anchor component styles links with Garden’s typography and color system.
Basic Usage
p(Anchor('Click here', href='#'))Danger
p(Anchor('Delete this', href='#', cls='--danger'))Dark
For use on dark backgrounds.
p(Div(Anchor('Dark link', href='#', cls='--dark'), style='background:#333; padding:1rem'))Avatars
Styled avatar images with Garden’s sizing and shape system.
Basic Usage
An Avatar can contain an image or text
p(Avatar(Img(src='https://ui-avatars.com/api/?name=John+Doe')))p(Div(
Avatar(Img(src='https://picsum.photos/200')),
Avatar(AvatarTxt('ZD'), style='background:var(--zd-color-secondary-royal-700)'),
style='display:flex; gap:1rem; align-items:center'
))print(Avatar(Span('ZD', cls='c-avatar__txt', style='background:--zd-color-secondary-royal-700'), cls='--system'))<figure class="c-avatar c-avatar--system "><span class="c-avatar__txt" style="background:--zd-color-secondary-royal-700">ZD</span></figure>
Sizes
Avatars come in extra-small, small, default, and large sizes.
p(Div(
Avatar(Img(src='https://ui-avatars.com/api/?name=XS'), cls='--xs'),
Avatar(Img(src='https://ui-avatars.com/api/?name=SM'), cls='--sm'),
Avatar(Img(src='https://ui-avatars.com/api/?name=MD')),
Avatar(Img(src='https://ui-avatars.com/api/?name=LG'), cls='--lg')
))System
Square avatars for system/product icons.
p(Avatar(Img(src='https://ui-avatars.com/api/?name=SYS'), cls='--system'))Dark
For use on dark backgrounds.
p(Div(Avatar(Img(src='https://ui-avatars.com/api/?name=DK'), cls='--dark'), style='background:#333; padding:1rem'))Forms
Garden forms combine inputs with labels, hints, and validation messages inside a c-field container.
Basic Usage
Text Input
p(Field(
FieldLabel('Name', fr='name-id'),
FieldHint('Enter your full name'),
FieldInput(id='name-id', placeholder='John Doe')
))Textarea
p(Field(
FieldLabel('Bio', fr='bio-id'),
Textarea(id='bio-id', placeholder='Tell us about yourself')
))Select
p(Field(
FieldLabel('Country', fr='country-id'),
Select(Option('USA'), Option('UK'), Option('Canada'), id='country-id')
))Checkbox
p(Field(
Checkbox(id='agree-id'),
FieldLabel('I agree to the terms', fr='agree-id'),
FieldHint('Please read carefully')
))Radio
p(Div(
Field(Radio(id='opt1', name='options'), FieldLabel('Option 1', fr='opt1')),
Field(Radio(id='opt2', name='options'), FieldLabel('Option 2', fr='opt2')),
Field(Radio(id='opt3', name='options'), FieldLabel('Option 3', fr='opt3'))
))Validation States
p(Field(
FieldLabel('Email'), FieldInput(),
FieldMessage('Valid email', cls='--success'),
cls='--success'
))p(Field(
FieldLabel('Password'), FieldInput(type='password'),
FieldMessage('Password too weak', cls='--warning'),
cls='--warning'
))p(Field(
FieldLabel('Username'), FieldInput(),
FieldMessage('Username is required', cls='--error'),
cls='--error'
))Compact and Dark
p(Field(FieldLabel('Compact'), FieldInput(), cls='--compact'))p(Div(
Field(FieldLabel('Dark mode'), FieldInput(), cls='--dark'),
style='background:#333; padding:1rem'
))