fractalsvelte mascot fractalsvelte fractalsvelte

Svelte 5 component · machines-ui · Frame

ButtonMachine

A button drawn as a dashed frame with the label set in a block of the current accent. The label turns black or white to stay readable on whatever the accent is. Pass `href` and it renders a link.

Install

ButtonMachine is a Svelte 5 ASCII button machine component in @fractaldesign/machines-ui. It works in SvelteKit and in any Svelte 5 app.

pnpm add @fractaldesign/machines-ui

Import

import
import '@fractaldesign/machines-ui/style.css';
import { ButtonMachine } from '@fractaldesign/machines-ui';

Usage

Example 1
<ButtonMachine onclick={() => console.log('run')}>Run</ButtonMachine>
Example 2
<ButtonMachine href="/docs">Docs</ButtonMachine>

Props

NameTypeDefault
href string Makes it a link: an `<a>` with this address instead of a `<button>`.—
type 'button' | 'submit' | 'reset' The `type` of the `<button>`. Not used when `href` is set. Default 'button'.'button'
disabled boolean Disables the `<button>`. Not used when `href` is set. Default false.false
onclick (event: MouseEvent) => void Called when the button or link is clicked.—
class string Extra classes on the outer element.''
children Snippet The label.—

Snippets

NameTypeDefault
default unknown —