IconButton playground
A named icon control with independent glyph and hit-target sizes and an optional controlled pressed state.
Preview
Props editor
State matrix
Hover a specimen, Tab to focus, or hold the pointer down to inspect its native state.
| Variant | Default | Hover | Focus-visible | Active | Disabled |
|---|---|---|---|---|---|
| ghost / sm | |||||
| ghost / md | |||||
| secondary / sm | |||||
| secondary / md |
Published example
API reference'use client'
import { useState } from 'react'
import { IconButton } from '@ancrel/ui'
import '@ancrel/tokens/css'
import '@ancrel/ui/styles.css'
export default function App() {
const [pinned, setPinned] = useState(false)
return (
<section aria-label="Note actions">
<IconButton aria-label="Pin note" pressed={pinned} onClick={() => setPinned(value => !value)}
icon={<svg viewBox="0 0 16 16" fill="currentColor"><path d="m5 2 6 0-1 4 2 3v1H8.7L8 15l-.7-5H4V9l2-3Z" /></svg>}
/>
<span>{pinned ? 'Pinned' : 'Unpinned'}</span>
</section>
)
}