kor TürkçeGitHub

Button

Starts an action. Five kinds tell the user how much weight the action carries.

kor/ui/ButtonSource

When to use

  • One primary button per screen area: the action most people came for.
  • Accent only for a single, decisive action such as Approve.
  • Ghost for icon buttons and tools that repeat in every row.

When not to use

  • An irreversible action: use HoldButton or Confirm.
  • Switching between views: use Segmented or Tabs.

Examples

Kinds

Loading the example

<k:Stack row="true" gap="10">
	<k:Button kind="primary" text="Save" press=".onPress"/>
	<k:Button kind="accent" text="Approve" icon="check" press=".onPress"/>
	<k:Button text="Duplicate" press=".onPress"/>
	<k:Button kind="ghost" icon="palette" label="Appearance" press=".onPress"/>
	<k:Button kind="danger" text="Reject" press=".onPress"/>
</k:Stack>

Menu

Add menuItems and the button opens a menu. menuSelect carries the key of the chosen row.

Loading the example

<k:Button text="Export" menuSelect=".onMenu">
	<k:MenuItem key="xlsx" text="Excel"/>
	<k:MenuItem key="csv" text="CSV"/>
</k:Button>

Loading and disabled

loading blocks further presses until you set it back to false.

Loading the example

<k:Stack row="true" gap="10">
	<k:Button kind="primary" text="Post invoice" loading="{/busy}" press=".onPost"/>
	<k:Button text="Not available" enabled="false"/>
</k:Stack>

Keyboard

Enter Space
Press, or open the menu
↓
Open the menu
Esc
Close the menu

API

Properties

NameTypeDefaultDescription
textstringButton text
iconstringIcon name
kindstringneutralprimary, accent, neutral, ghost or danger
hintstringDisplayed keyboard shortcut
labelstringAccessible name and tooltip for an icon-only button
loadingbooleanfalseWhether an operation is in progress
enabledbooleantrueWhether the button can be used
widebooleanfalseWhether the button fills its container

Aggregations

NameTypeDescription
menuItemsMenuItem[]Menu entries

Events

NameTypeDescription
pressThe button was pressed
menuSelectkey: stringA menu entry was selected

An entry in a button's menu.

Properties

NameTypeDefaultDescription
keystringEntry key
textstringMenu text
iconstringIcon name
dangerbooleanfalseWhether the action is hard to reverse

Related

HoldButtonSegmentedConfirm