Skip to content

Button

Buttons are used to initialize an action, such as submitting a form, cancelling an action, or performing a page specific operation. Buttons can also be used for navigation when styled as a link.

The default button for most actions.

Use micro buttons in tight spaces.

Disabled buttons indicate that an action is not currently available.

<script>
import { Button } from 'svelte-polaris';
</script>
<Button disabled>
Unavailable action
</Button>
<Button variant="primary" disabled>
Submit (disabled)
</Button>

Loading buttons show progress for asynchronous actions.

<script>
import { Button } from 'svelte-polaris';
</script>
<Button loading>
Processing...
</Button>
<Button variant="primary" loading>
Saving changes
</Button>

Pressed state indicates that a toggle button is currently active.

<script>
import { Button } from 'svelte-polaris';
</script>
<Button pressed>
Active filter
</Button>
<Button variant="tertiary" pressed>
Bold text
</Button>

Use icon-only buttons when space is limited and the icon meaning is clear.

<script>
import { Button } from 'svelte-polaris';
import { SearchIcon, DeleteIcon, EditIcon } from 'svelte-polaris/icons';
</script>
<Button accessibilityLabel="Search" icon={SearchIcon} />
<Button accessibilityLabel="Delete" icon={DeleteIcon} tone="critical" />
<Button accessibilityLabel="Edit" icon={EditIcon} variant="plain" />

Combine icons with text to provide both visual and textual context.

<script>
import { Button } from 'svelte-polaris';
import { PlusIcon, SaveIcon, ExportIcon } from 'svelte-polaris/icons';
</script>
<Button icon={PlusIcon}>
Add product
</Button>
<Button icon={SaveIcon} variant="primary">
Save changes
</Button>
<Button icon={ExportIcon} variant="tertiary">
Export data
</Button>

Disclosure buttons indicate that clicking will reveal additional options.

<script>
import { Button } from 'svelte-polaris';
</script>
<!-- Default down disclosure -->
<Button disclosure>
More actions
</Button>
<!-- Up disclosure -->
<Button disclosure="up">
Show less
</Button>
<!-- Select disclosure -->
<Button disclosure="select">
Choose option
</Button>

Full width buttons span the entire width of their container.

<script>
import { Button } from 'svelte-polaris';
</script>
<Button fullWidth>
Full width button
</Button>
<Button fullWidth variant="primary">
Primary full width
</Button>

Control how text is aligned within the button.

<script>
import { Button } from 'svelte-polaris';
</script>
<Button fullWidth textAlign="left">
Left aligned
</Button>
<Button fullWidth textAlign="center">
Center aligned
</Button>
<Button fullWidth textAlign="right">
Right aligned
</Button>

Buttons can also function as links when a URL is provided.

<script>
import { Button } from 'svelte-polaris';
</script>
<!-- Internal link -->
<Button url="/products">
View products
</Button>
<!-- External link -->
<Button url="https://shopify.com" external>
Visit Shopify
</Button>
<!-- Download link -->
<Button url="/report.pdf" download>
Download report
</Button>
PropTypeDefaultDescription
variant'plain' | 'primary' | 'secondary' | 'tertiary' | 'monochromePlain''secondary'Changes the visual appearance of the button
tone'critical' | 'success'-Sets the color treatment of the button
size'micro' | 'slim' | 'medium' | 'large''medium'Changes the size of the button
textAlign'left' | 'right' | 'center' | 'start' | 'end''start'Changes the inner text alignment
fullWidthbooleanfalseAllows the button to grow to the width of its container
disabledbooleanfalseDisables the button
loadingbooleanfalseShows loading state with spinner
pressedbooleanfalseIndicates the pressed state for toggle buttons
disclosure'down' | 'up' | 'select' | booleanfalseDisplays the button with a disclosure icon
iconIconSource-Icon to display to the left of the button content
urlstring-A destination to link to, rendered in the href attribute of a link
externalbooleanfalseForces url to open in a new tab
downloadboolean | stringfalseTells the browser to download the url instead of opening it
accessibilityLabelstring-Visually hidden text for screen readers
onClick() => void-Callback when button is clicked
  • Always provide descriptive text or accessibilityLabel for screen readers
  • Use semantic tone props to convey meaning (critical for destructive actions)
  • Ensure sufficient color contrast for all button variants
  • Consider focus states and keyboard navigation
  • For icon-only buttons, always include accessibilityLabel

Use primary buttons sparingly

Only one primary button per page section to maintain clear hierarchy.

Choose appropriate variants

Match the visual weight to the action importance.

Provide clear labels

Button text should clearly describe the action that will occur.

Consider loading states

Always show progress for async actions to provide user feedback.

  • ButtonGroup - For grouping related buttons
  • Link - For navigation that doesn’t trigger actions
  • ActionList - For lists of actions in menus