You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
Socket
Sign inDemoInstall
Socket

@telegraph/button

Package Overview
Dependencies
Maintainers
2
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@telegraph/button

Button component in Telegraph

0.0.77
latest
Source
npm
Version published
Weekly downloads
14K
1.09%
Maintainers
2
Weekly downloads
 
Created
Source

Telegraph by Knock

npm version

@telegraph/button

A button component

Installation Instructions

npm install @telegraph/button

Add stylesheet

@import "@telegraph/button"

Basic Usage

Shorthand button component that adheres to the telegraph design system

<Button/>
import { Button } from "@telegraph/button"

...

<Button>Button</Button>
Props
NameTypeDefaultOptions
variantstring"solid""solid", "soft", "outline", "ghost"
sizestring"2""1", "2", "3"
colorstring"gray""accent", "gray", "red"
leadingIconIconProps{icon: undefined, alt: undefined}See @telegraph/icon exported icons
trailingIconIconProps{icon: undefined, alt: undefined}See @telegraph/icon exported icons
iconIconProps{icon: undefined, alt: undefined}See @telegraph/icon exported icons

Advanced Usage

Individual parts of the button component that can be composed in configurations different from the default telegraph design system styles. This can be used to create modifications to one-off button components without the need to modify the button exported from this package.

<Button.Root/>

Contains all the individual parts of the button component, relays props to children, and handles defining styles for the layout of the button.

import { Button } from "@telegraph/button"

...

<Button.Root></Button.Root>
Props
NameTypeDefaultOptions
variantstring"solid""solid", "soft", "outline", "ghost"
sizestring"2""1", "2", "3"
colorstring"gray""accent", "gray", "red"
<Button.Text/>

A component built on top of the Text component from @telegraph/typography with translated props to adhere to the telegraph design system

import { Button } from "@telegraph/button"

...

<Button.Text>Text</Button.Text>
Props

Note: <Button.Root/> handles setting the styles of the text component. These props can be overriden by passing the props available to @telegraph/typography directly to <Button.Text/>, i.e. <Button.Text size="9" weight="medium" color="beige" align="right">Text</Button.Text>

<Button.Icon/>

A component built on top of the Icon component from @telegraph/icon with translated props to adhere to the telegraph design system

import { Button } from "@telegraph/button"
import { checkmark } from "@telegraph/icon"

...

<Button.Icon icon={checkmark} alt="item is selected"/>
Props
NameTypeDefaultOptions
iconstringundefinedSee @telegraph/icon exported icons
altstringundefined
colorstring"gray""accent", "gray", "red"

Note: <Button.Root/> handles setting the styles of the icon component. These props can be overriden by passing the props available to @telegraph/icon directly to <Button.Icon/>, i.e. <Button.Icon size="4" variant="secondary" color="blue"/>

An example of composing an advanced button
import { Button } from "@telegraph/button"
import { checkmark } from "@telegraph/icon"

<Button.Root color="accent" variant="soft">
    <Button.Icon icon={checkmark} alt="item is selected">
    <Button.Text>Text</Button.Text>
</Button.Root>

FAQs

Package last updated on 04 Apr 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts