Button Svelte Component
Button Svelte component represents Framework7's Button elements.
Button Components
There are following components included:
- Button- single button
Button Properties
Button component has almost the same properties as the Link component but with few additional button-specific properties:
| Prop | Type | Default | Description | 
|---|---|---|---|
| <Button> properties | |||
| type | string | If it is one of submit,buttonorresetthen it will be rendered as<button>element with sametypeattribute | |
| tabLink | string boolean | Enables tab link and specify CSS selector of the target tab (if specified as a string) | |
| tabLinkActive | boolean | false | Makes this tab link active | 
| active | boolean | false | Makes this button active state when used in Segmented. Must be used instead of tab-link-active | 
| text | string | Button text label | |
| tooltip | string | Button tooltip text to show on button hover/press | |
| tooltipTrigger | string | hover | Defines how to trigger (open) Tooltip. Can be hover,clickormanual | 
| round | boolean | false | Makes button round | 
| roundIos | boolean | false | Makes button round for iOS theme only | 
| roundMd | boolean | false | Makes button round for MD theme only | 
| large | boolean | false | Makes large button | 
| largeIos | boolean | false | Makes large button for iOS theme only | 
| largeMd | boolean | false | Makes large button for MD theme only | 
| small | boolean | false | Makes small button | 
| smallIos | boolean | false | Makes small button for iOS theme only | 
| smallMd | boolean | false | Makes small button for MD theme only | 
| fill | boolean | false | Makes button filled color | 
| fillIos | boolean | false | Makes button filled color for iOS theme only | 
| fillMd | boolean | false | Makes button filled color for MD theme only | 
| tonal | boolean | false | Makes tonal style button | 
| tonalIos | boolean | false | Makes tonal style button for iOS theme only | 
| tonalMd | boolean | false | Makes tonal style button for MD theme only | 
| raised | boolean | false | Makes button raised | 
| raisedIos | boolean | false | Makes button raised only in iOS theme | 
| raisedMd | boolean | false | Makes button raised only in MD theme | 
| outline | boolean | false | Makes button outline | 
| outlineIos | boolean | false | Makes button outline only in iOS theme | 
| outlineMd | boolean | false | Makes button outline only in MD theme | 
| <Button> preloader related properties | |||
| preloader | boolean | false | Enables button to have preloader | 
| loading | boolean | false | Controls button state to show/hide preloader and hide/show button text (switch button to loading state) | 
| preloaderColor | string | button's preloader color | |
| preloaderSize | number string | button's preloader size | |
| <Button> icon related properties | |||
| iconSize | string number | Icon size in px | |
| iconColor | string | Icon color. One of the default colors | |
| icon | string | Custom icon class | |
| iconF7 | string | Name of F7 Icons font icon | |
| iconMaterial | string | Name of Material Icons font icon | |
| iconIos | string | Icon to be used in case of iOS theme is used. Consists of icon family and icon name divided by colon, e.g. f7:house | |
| iconMd | string | Icon to be used in case of MD theme is used. Consists of icon family and icon name divided by colon, e.g. material:home | |
| <Button> navigation/router related properties | |||
| href | string boolean | # | URL of the page to load. In case of boolean href="false"it won't addhreftag | 
| target | string | Value of link target attribute, e.g. _blank,_self, etc. | |
| view | string | CSS selector of the View to load the page. Or currentto load in current view. | |
| external | boolean | Enable to bypass Framework7's link click handler | |
| back | boolean | Enables back navigation link | |
| openIn | string | Allows open page route as modal or panel. Can be popup,loginScreen,sheet,popoverorpanel | |
| force | boolean | Force page to load and ignore previous page in history (use together with backprop) | |
| reloadCurrent | boolean | Reloads new page instead of the currently active one | |
| reloadPrevious | boolean | Replace the previous page in history with the new one from route | |
| reloadAll | boolean | Load new page and remove all previous pages from history and DOM | |
| reloadDetail | boolean | Reload Detail page in Master Detail view | |
| animate | boolean | Disables pages animation | |
| transition | string | Name of the custom page transition | |
| ignoreCache | boolean | Ignores caching | |
| routeTabId | string | Routable Tab id | |
| routeProps | object | Object with additional props that will be passed to target route component | |
| preventRouter | boolean | false | If set, then it won't be processed by Framework7 router | 
| <Button> action related properties | |||
| panelOpen | string boolean | CSS selector of panel to open on click. Or can be leftorrightif there is only left or right panel in DOM. | |
| panelClose | string boolean | Closes panel on click | |
| panelToggle | string boolean | CSS selector of panel to toggle on click. Or can be leftorrightif there is only left or right panel in DOM. | |
| actionsOpen | string boolean | CSS selector of the action sheet to open on click | |
| actionsClose | string boolean | CSS selector of the action sheet to close on click. Or boolean property to close currently opened action sheet | |
| popupOpen | string boolean | CSS selector of the popup to open on click | |
| popupClose | string boolean | CSS selector of the popup to close on click. Or boolean property to close currently opened popup | |
| popoverOpen | string boolean | CSS selector of the popover to open on click | |
| popoverClose | string boolean | CSS selector of the popover to close on click. Or boolean property to close currently opened popover | |
| sheetOpen | string boolean | CSS selector of the sheet modal to open on click | |
| sheetClose | string boolean | CSS selector of the sheet modal to close on click. Or boolean property to close currently opened sheet modal | |
| loginScreenOpen | string boolean | CSS selector of the login screen to open on click | |
| loginScreenClose | string boolean | CSS selector of the login screen to close on click. Or boolean property to close currently opened login screen | |
| sortableEnable | string boolean | CSS selector of the Sortable list to be enabled on click | |
| sortableDisable | string boolean | CSS selector of the Sortable list to be disabled on click. Or boolean property to close currently opened Sortable list | |
| sortableToggle | string boolean | CSS selector of the Sortable list to toggle on click. Or boolean property to toggle currently opened/closed Sortable list | |
| searchbarEnable | string boolean | CSS selector of the Expandable Searchbar to be enabled on click. Or boolean property to enable the first found Searchbar | |
| searchbarDisable | string boolean | CSS selector of the Expandable Searchbar to be disabled on click. Or boolean property to disable the first found Searchbar | |
| searchbarToggle | string boolean | CSS selector of the Expandable Searchbar to toggle on click. Or boolean property to toggle the first found Searchbar | |
| searchbarClear | string boolean | CSS selector of the Expandable Searchbar to clear on click. Or boolean property to clear the first found Searchbar | |
| cardOpen | string boolean | CSS selector of the expandable card to open on click. Or boolean to open first found expandable card | |
| cardClose | string boolean | CSS selector of the expandable card to close on click. Or boolean property to close currently opened expandable card | |
| cardPreventOpen | boolean | Click on element with this prop won't open its parent expandable card | |
Button Events
| Event | Description | 
|---|---|
| <Button> events | |
| click | Event will be triggered after click on a button | 
Examples
buttons.svelte
      
    <script>
  import {
    Page,
    Navbar,
    BlockTitle,
    Block,
    Button,
  } from 'framework7-svelte';
  let isLoading1 = false;
  let isLoading2 = false;
  const load1 = () => {
    if (isLoading1) return;
    isLoading1 = true;
    setTimeout(() => {
      isLoading1 = false;
    }, 4000);
  };
  const load2 = () => {
    if (isLoading2) return;
    isLoading2 = true;
    setTimeout(() => {
      isLoading2 = false;
    }, 4000);
  };
</script>
<!-- svelte-ignore a11y-invalid-attribute -->
<Page>
  <Navbar title="Buttons" />
  <BlockTitle>Usual Buttons</BlockTitle>
  <Block strong outlineIos>
    <div class="grid grid-cols-3 grid-gap">
      <Button>Button</Button>
      <Button>Button</Button>
      <Button round>Round</Button>
    </div>
  </Block>
  <BlockTitle>Tonal Buttons</BlockTitle>
  <Block strong outlineIos>
    <div class="grid grid-cols-3 grid-gap">
      <Button tonal>Button</Button>
      <Button tonal>Button</Button>
      <Button tonal round>Round</Button>
    </div>
  </Block>
  <BlockTitle>Fill Buttons</BlockTitle>
  <Block strong outlineIos>
    <div class="grid grid-cols-3 grid-gap">
      <Button fill>Button</Button>
      <Button fill>Button</Button>
      <Button fill round>Round</Button>
    </div>
  </Block>
  <BlockTitle>Outline Buttons</BlockTitle>
  <Block strong outlineIos>
    <div class="grid grid-cols-3 grid-gap">
      <Button outline>Button</Button>
      <Button outline>Button</Button>
      <Button outline round>Round</Button>
    </div>
  </Block>
  <BlockTitle>Raised Buttons</BlockTitle>
  <Block strong outlineIos>
    <p class="grid grid-cols-3 grid-gap">
      <Button raised>Button</Button>
      <Button raised fill>Fill</Button>
      <Button raised outline>Outline</Button>
    </p>
    <p class="grid grid-cols-3 grid-gap">
      <Button raised round>Round</Button>
      <Button raised fill round>Fill</Button>
      <Button raised outline round>Outline</Button>
    </p>
  </Block>
  <BlockTitle>Large Buttons</BlockTitle>
  <Block strong outlineIos>
    <p class="grid grid-cols-2 grid-gap">
      <Button large>Button</Button>
      <Button large fill>Fill</Button>
    </p>
    <p class="grid grid-cols-2 grid-gap">
      <Button large raised>Raised</Button>
      <Button large raised fill>Raised Fill</Button>
    </p>
    <p class="grid grid-cols-2 grid-gap">
      <Button large round>Round</Button>
      <Button large round fill>Round Fill</Button>
    </p>
  </Block>
  <BlockTitle>Small Buttons</BlockTitle>
  <Block strong outlineIos>
    <p class="grid grid-cols-3 grid-gap">
      <Button small>Button</Button>
      <Button small outline>Outline</Button>
      <Button small fill>Fill</Button>
    </p>
    <p class="grid grid-cols-3 grid-gap">
      <Button small round>Button</Button>
      <Button small outline round>Outline</Button>
      <Button small fill round>Fill</Button>
    </p>
  </Block>
  <BlockTitle>Preloader Buttons</BlockTitle>
  <Block strong outlineIos>
    <p class="grid grid-cols-3 grid-gap">
      <Button preloader loading={isLoading1} onClick={load1} large>Load</Button>
      <Button preloader loading={isLoading2} onClick={load2} large fill>Load</Button>
    </p>
  </Block>
  <BlockTitle>Color Buttons</BlockTitle>
  <Block strong outlineIos>
    <div class="grid grid-cols-3 grid-gap">
      <Button color="red">Red</Button>
      <Button color="green">Green</Button>
      <Button color="blue">Blue</Button>
    </div>
  </Block>
  <BlockTitle>Color Fill Buttons</BlockTitle>
  <Block strong outlineIos>
    <p class="grid grid-cols-3 grid-gap">
      <Button color="red">Red</Button>
      <Button color="green">Green</Button>
      <Button color="blue">Blue</Button>
    </p>
    <p class="grid grid-cols-3 grid-gap">
      <Button color="pink">Pink</Button>
      <Button color="yellow">Yellow</Button>
      <Button color="orange">Orange</Button>
    </p>
    <p class="grid grid-cols-3 grid-gap">
      <Button color="black">Black</Button>
      <Button color="white">White</Button>
    </p>
  </Block>
</Page>
