UI components · Actions
Button
A native button, or a link with href. Group: Actions · component 1 of 17, new in silverpoint 0.3.
States
The 4 reference states silverpoint declares for Button, live on both grounds, with their code. As in upstream's documentation the examples are uncontrolled: the state's value is the default value. Pick a framework once and every example on the site follows it.
default
import '@silverpoint/fonts/fonts.css';
import '@silverpoint/grounds/styles.css';
import '@silverpoint/grounds/ui.css';
import { SpButton } from '@silverpoint/react/ui/button';
<SpButton>Default</SpButton><script setup lang="ts">
import '@silverpoint/fonts/fonts.css';
import '@silverpoint/grounds/styles.css';
import '@silverpoint/grounds/ui.css';
import { SpButton } from '@silverpoint/vue/ui/button';
</script>
<template>
<SpButton>
Default
</SpButton>
</template>// src/styles.css:
// @import '@silverpoint/fonts/fonts.css';
// @import '@silverpoint/grounds/styles.css';
// @import '@silverpoint/grounds/ui.css';
import { Component } from '@angular/core';
import { SpButton } from '@silverpoint/angular/ui/button';
@Component({
selector: 'app-root',
imports: [SpButton],
template: `
<button spButton>Default</button>
`,
})
export class App {}from reflex_silverpoint_react import sp_button
sp_button(
"Default",
)primary
import '@silverpoint/fonts/fonts.css';
import '@silverpoint/grounds/styles.css';
import '@silverpoint/grounds/ui.css';
import { SpButton } from '@silverpoint/react/ui/button';
<SpButton variant="primary">Primary</SpButton><script setup lang="ts">
import '@silverpoint/fonts/fonts.css';
import '@silverpoint/grounds/styles.css';
import '@silverpoint/grounds/ui.css';
import { SpButton } from '@silverpoint/vue/ui/button';
</script>
<template>
<SpButton variant="primary">
Primary
</SpButton>
</template>// src/styles.css:
// @import '@silverpoint/fonts/fonts.css';
// @import '@silverpoint/grounds/styles.css';
// @import '@silverpoint/grounds/ui.css';
import { Component } from '@angular/core';
import { SpButton } from '@silverpoint/angular/ui/button';
@Component({
selector: 'app-root',
imports: [SpButton],
template: `
<button spButton variant="primary">Primary</button>
`,
})
export class App {}from reflex_silverpoint_react import sp_button
sp_button(
"Primary",
variant="primary",
)danger
import '@silverpoint/fonts/fonts.css';
import '@silverpoint/grounds/styles.css';
import '@silverpoint/grounds/ui.css';
import { SpButton } from '@silverpoint/react/ui/button';
<SpButton variant="danger">Delete</SpButton><script setup lang="ts">
import '@silverpoint/fonts/fonts.css';
import '@silverpoint/grounds/styles.css';
import '@silverpoint/grounds/ui.css';
import { SpButton } from '@silverpoint/vue/ui/button';
</script>
<template>
<SpButton variant="danger">
Delete
</SpButton>
</template>// src/styles.css:
// @import '@silverpoint/fonts/fonts.css';
// @import '@silverpoint/grounds/styles.css';
// @import '@silverpoint/grounds/ui.css';
import { Component } from '@angular/core';
import { SpButton } from '@silverpoint/angular/ui/button';
@Component({
selector: 'app-root',
imports: [SpButton],
template: `
<button spButton variant="danger">Delete</button>
`,
})
export class App {}from reflex_silverpoint_react import sp_button
sp_button(
"Delete",
variant="danger",
)disabled
import '@silverpoint/fonts/fonts.css';
import '@silverpoint/grounds/styles.css';
import '@silverpoint/grounds/ui.css';
import { SpButton } from '@silverpoint/react/ui/button';
<SpButton disabled>Disabled</SpButton><script setup lang="ts">
import '@silverpoint/fonts/fonts.css';
import '@silverpoint/grounds/styles.css';
import '@silverpoint/grounds/ui.css';
import { SpButton } from '@silverpoint/vue/ui/button';
</script>
<template>
<SpButton disabled>
Disabled
</SpButton>
</template>// src/styles.css:
// @import '@silverpoint/fonts/fonts.css';
// @import '@silverpoint/grounds/styles.css';
// @import '@silverpoint/grounds/ui.css';
import { Component } from '@angular/core';
import { SpButton } from '@silverpoint/angular/ui/button';
@Component({
selector: 'app-root',
imports: [SpButton],
template: `
<button spButton [disabled]="true">Disabled</button>
`,
})
export class App {}from reflex_silverpoint_react import sp_button
sp_button(
"Disabled",
disabled=True,
)Import
Each component has its own subpath under ui/, and every adapter exports them all from ui. Import @silverpoint/grounds/ui.css once, beside styles.css; Reflex adds it for you.
| Framework | Import |
|---|---|
| React | import { SpButton } from '@silverpoint/react/ui/button'; |
| Vue | import { SpButton } from '@silverpoint/vue/ui/button'; |
| Angular | import { SpButton } from '@silverpoint/angular/ui/button'; // <button spButton> |
| Reflex | from reflex_silverpoint_react import sp_button |
Props
The props Button adds to the ones every UI component takes.
| React / Angular | Vue | Reflex | Type | Description |
|---|---|---|---|---|
variant | variant | variant | Literal['default', 'primary', 'danger'] | default, primary or danger (which also draws the exact ✕ glyph). |
type | type | type | Literal['submit', 'reset', 'button'] | button (default), submit or reset. |
disabled | disabled | disabled | bool | Not focusable, not submitted; drawn with the disabled tone. |
label | label | label | str | Accessible name of an icon-only button. |
block | block | block | bool | Fills the width of its container. |
href | href | href | str | Renders an <a> to this address. |
Common props
Every UI component also takes these. Like a chart's, they fall back to the dashboard the component sits in, then to the provider. Read more about the UI components.
| React / Angular | Vue | Reflex | Type | Description |
|---|---|---|---|---|
id | id | id | str | The frame variant and every related id derive from it. |
ground | ground | ground | Literal['silverpoint', 'cyanotype'] | str | dict[str, Any] | Style ground: "silverpoint" or "cyanotype", or a ground object. Defaults to the dashboard's, then the provider's, or silverpoint. |
substrate | substrate | substrate | Literal['cream', 'green', 'blue', 'ochre', 'prussian'] | Prepared substrate within the ground. |
mode | mode | mode | Literal['ink', 'precision'] | ink by default; precision disables inking. |
seed | seed | seed | str | int | Seed of the frame's hand; overrides id for the frame variant only. |
size | size | size | Literal['sm', 'md', 'lg'] | Control size: sm, md (default) or lg. |
palette | palette | palette | dict[str, str] | Colours over the ground's (set with palette=), merged over the dashboard's and the provider's. |
className | class-name | class_name | str | Added to the component's root element, after its own classes. |
Report it
Found something wrong with SpButton? Open an issue on GitHub — the form comes pre-filled with the component and the version.