Button

button — universal action button

The single, opinionated button used across CzG projects. Three variants (primary, ghost, link), three sizes (sm/md/lg). Renders <button> for form/JS actions or <a> when href is provided — same look, semantic HTML.

Install

npx czg-ui add button

@import 'components/button'; to app.scss (after base). No JS.

Requires base.

Parameters

ParamTypeDefaultNotes
variantstring'primary'primary \ghost \link
sizestring'md'sm \md \lg
typestring'button'button \submit (ignored when href is set)
hrefstring\nullIf set, renders <a> instead of <button>
disabledboolfalseAdds disabled attribute (button only)
labelstringVisible text

Variants — when to use what

VariantUse forExample
primaryThe single most important action on screen"Odeslat objednávku"
ghostSecondary actions next to the primary one"Zrušit", "Zpět"
linkTertiary, low-emphasis actions inline with text"Zobrazit více"

Rule of thumb: one primary per view. If you have two primaries, either one of them is actually a ghost, or the design needs a redesign.

Usage

{include /app/components/Button/button.latte,
    variant => 'primary',
    size    => 'lg',
    href    => $presenter->link('Order:'),
    label   => 'Objednat'}

{include /app/components/Button/button.latte,
    variant => 'ghost',
    type    => 'submit',
    label   => 'Uložit'}

Accessibility

  • Default type="button" prevents accidental form submits
  • disabled removes the element from tab order automatically
  • :focus-visible outline via cgui-focus-visible mixin (keyboard only)

When NOT to use

  • Icon-only actions — use a dedicated icon-button (smaller hit

area, different padding, aria-label required)

  • Toggle states — use a <button aria-pressed> or a switch component

Live preview

ui.czechgroup.cz/component/button

Další kategorie