Button

A flexible interactive button element supporting variants, sizes, icons, loading state, and full-width layout. variant="none" makes it the library's unstyled pressable: custom tiles, pads and rows keep real button behavior without a bare Pressable.

Basics

Label a button with title (or children) and pass onPress to run its action.

Loading demo…

import { Button } from '@plocks/ui'; export function Demo() { return <Button title="Launch mission" />; }

Colors

Pair color with a color-bearing variant (filled, light, subtle, outline, gradient) to align actions with brand intent. With no variant, color alone gives a filled button whose text contrasts automatically. An explicit variant="default" stays neutral and ignores color.

Loading demo…

import { Button, Row } from '@plocks/ui'; export function Demo() { return ( <Row gap="md" wrap="wrap"> <Button color="primary">Primary</Button> <Button color="secondary">Secondary</Button> <Button color="success">Success</Button> <Button color="warning">Warning</Button> <Button color="error">Error</Button> <Button color="#5865F2">Custom</Button> </Row> ); }

Loading state

Set loading to swap the label for a spinner and block presses. Add loadingTitle to keep text beside the spinner.

Loading demo…

import { Button, Row } from '@plocks/ui'; export function Demo() { return ( <Row gap="md" wrap="wrap"> <Button loading>Submit application</Button> <Button loading loadingTitle="Submitting…"> Submit application </Button> </Row> ); }

Variants

Preview the available button variants to match the desired emphasis level.

Loading demo…

import { Button, Row } from '@plocks/ui'; export function Demo() { return ( <Row gap="md" wrap="wrap"> <Button variant="default">Default</Button> <Button variant="filled">Filled</Button> <Button variant="light">Light</Button> <Button variant="subtle">Subtle</Button> <Button variant="secondary">Secondary</Button> <Button variant="outline">Outline</Button> <Button variant="gradient">Gradient</Button> <Button variant="ghost">Ghost</Button> <Button variant="none">Text only</Button> </Row> ); }

Unstyled pressable

variant="none" drops the chrome — no fill, border, padding or fixed height — and keeps the button: its role and name, keyboard focus and focus ring, press feedback, haptics, disabled, tooltip and onLongPress. Use it for pressables whose children are the whole look (tiles, pads, rows, swatches) instead of a bare Pressable or a Block with onPress. IconButton variant="none" is the icon-only form.

Loading demo…

import { useState } from 'react'; import { Block, Button, IconButton, Row, Text } from '@plocks/ui'; const TILES = [ { id: 'kick', label: 'Kick', color: '#f97316' }, { id: 'snare', label: 'Snare', color: '#22c55e' }, { id: 'hat', label: 'Hat', color: '#3b82f6' }, ]; export function Demo() { const [picked, setPicked] = useState('kick'); const [starred, setStarred] = useState(false); return ( <Row gap="md" align="center" wrap="wrap"> {TILES.map((tile) => ( <Button key={tile.id} variant="none" accessibilityLabel={tile.label} aria-pressed={picked === tile.id} onPress={() => setPicked(tile.id)} style={{ borderRadius: 12 }} > <Block w={72} h={72} radius="md" justify="center" align="center" style={{ backgroundColor: tile.color, opacity: picked === tile.id ? 1 : 0.55 }} > <Text fw="700" c="white">{tile.label}</Text> </Block> </Button> ))} <IconButton variant="none" icon="heart" color={starred ? 'warning' : undefined} accessibilityLabel={starred ? 'Unstar' : 'Star'} onPress={() => setStarred((s) => !s)} /> </Row> ); }

Sizes

Preview the available button size tokens for different density requirements.

Loading demo…

import { Button, Row } from '@plocks/ui'; export function Demo() { return ( <Row gap="md" wrap="wrap" align="flex-end"> <Button size="sm">Small</Button> <Button size="md">Medium</Button> <Button size="lg">Large</Button> <Button size="xl">Extra large</Button> </Row> ); }

Localized labels

Switch locales at runtime and render translated button copy with useI18n helpers.

Loading demo…

import { Button, Flex, Select, useI18n } from '@plocks/ui'; const LOCALES = [ { label: 'English', value: 'en' }, { label: 'Español', value: 'es' }, { label: 'Français', value: 'fr' }, ]; export function Demo() { const { t, locale, setLocale } = useI18n(); return ( <Flex> <Select options={LOCALES} value={locale} onChange={(value) => { if (value) setLocale(value); }} /> <Button title={t('button.demo.submit')} /> </Flex> ); }

Tooltips

Add contextual hints to buttons with tooltip and optional placement overrides.

Loading demo…

import { Button, Row } from '@plocks/ui'; export function Demo() { return ( <Row gap="md" wrap="wrap"> <Button tooltip="Save your current work.">Save</Button> <Button tooltip={{ label: 'Permanently delete this item.', position: 'bottom' }}> Delete </Button> <Button tooltip={{ label: 'Download the file to your device.', position: 'left' }}> Download </Button> <Button tooltip={{ label: 'Get help and support resources.', position: 'right' }}> Help </Button> </Row> ); }

Width

Buttons hug their label by default. Set w to a pixel or percentage width, or fullWidth to fill the container. In a row, flex={1} makes buttons share the space equally.

Loading demo…

import { Block, Button, Row } from '@plocks/ui'; export function Demo() { return ( <Block fullWidth> <Button>Default width</Button> <Button w={200}>Fixed width (200)</Button> <Button w="50%">Half width (50%)</Button> <Button fullWidth>Full width</Button> <Row gap="sm"> <Button flex={1}>Cancel</Button> <Button flex={1} variant="filled">Save</Button> </Row> </Block> ); }
Scan to open this page on your phoneplocks.dev/ui/Button