본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

버튼 (ion-button)

원문 보기 위키 갱신

버튼(Button)은 클릭할 수 있는 요소를 제공해요. 폼(form)이나 단순하고 표준적인 버튼 기능이 필요한 어디에서든 사용할 수 있어요. 텍스트, 아이콘, 또는 둘 다를 표시할 수 있고, 여러 속성으로 원하는 모양으로 스타일링할 수 있어요.

출처: 문서

본문

Encapsulation: shadow

버튼은 클릭 가능한 요소를 제공해요. 폼이나 단순하고 표준적인 버튼 기능이 필요한 어디에서든 사용할 수 있어요. 텍스트, 아이콘, 또는 둘 다를 표시할 수 있어요. 버튼은 몇 가지 속성으로 특정한 모양을 갖도록 스타일링할 수 있어요.

Basic Usage

JavaScript

<ion-button>Default</ion-button> <ion-button disabled="true">Disabled</ion-button>

Angular

src/app/example.component.html

<ion-button>Default</ion-button> <ion-button [disabled]="true">Disabled</ion-button>

src/app/example.component.ts

import { Component } from '@angular/core';
import { IonButton } from '@ionic/angular';

@Component({
  selector: 'app-example',
  templateUrl: 'example.component.html',
  styleUrls: ['example.component.css'],
  imports: [IonButton],
})
export class ExampleComponent {}

React

import React from 'react';
import { IonButton } from '@ionic/react';

function Example() {
  return (
    <>
      <IonButton>Default</IonButton>
      <IonButton disabled={true}>Disabled</IonButton>
    </>
  );
}
export default Example;

Vue

<template>
  <ion-button>Default</ion-button>
  <ion-button :disabled="true">Disabled</ion-button>
</template>

<script setup lang="ts">
  import { IonButton } from '@ionic/vue';
</script>

Expand

이 프로퍼티는 버튼의 너비를 지정해요. 기본적으로 버튼은 display: inline-block이지만, 이 프로퍼티를 설정하면 display: block인 전체 너비(full-width) 요소로 바뀌어요.

JavaScript

<ion-button expand="block">Block</ion-button> <ion-button expand="full">Full</ion-button>

Angular

src/app/example.component.html

<ion-button expand="block">Block</ion-button> <ion-button expand="full">Full</ion-button>

src/app/example.component.ts

import { Component } from '@angular/core';
import { IonButton } from '@ionic/angular';

@Component({
  selector: 'app-example',
  templateUrl: 'example.component.html',
  styleUrls: ['example.component.css'],
  imports: [IonButton],
})
export class ExampleComponent {}

React

import React from 'react';
import { IonButton } from '@ionic/react';

function Example() {
  return (
    <>
      <IonButton expand="block">Block</IonButton>
      <IonButton expand="full">Full</IonButton>
    </>
  );
}
export default Example;

Vue

<template>
  <ion-button expand="block">Block</ion-button>
  <ion-button expand="full">Full</ion-button>
</template>

<script setup lang="ts">
  import { IonButton } from '@ionic/vue';
</script>

Shape

이 프로퍼티는 버튼의 모양을 지정해요. 기본적으로 버튼은 작은 테두리 반경을 가진 직사각형이지만, "round"로 설정하면 둥근 요소로 바뀌어요.

JavaScript

index.html

<ion-button>Default</ion-button>
<ion-button shape="round">Round</ion-button>
<ion-button>
  <ion-icon slot="icon-only" name="heart"></ion-icon>
</ion-button>
<ion-button shape="round">
  <ion-icon slot="icon-only" name="heart"></ion-icon>
</ion-button>

index.ts

import { defineCustomElements } from '@ionic/core/loader';

import { addIcons } from 'ionicons';
import { heart } from 'ionicons/icons';

/* Core CSS required for Ionic components to work properly */
import '@ionic/core/css/core.css';

/* Basic CSS for apps built with Ionic */
import '@ionic/core/css/normalize.css';
import '@ionic/core/css/structure.css';
import '@ionic/core/css/typography.css';

/* Optional CSS utils that can be commented out */
import '@ionic/core/css/padding.css';
import '@ionic/core/css/float-elements.css';
import '@ionic/core/css/text-alignment.css';
import '@ionic/core/css/text-transformation.css';
import '@ionic/core/css/flex-utils.css';
import '@ionic/core/css/display.css';

/**
 * Ionic Dark Palette
 * -----------------------------------------------------
 * For more information, please see:
 * https://ionicframework.com/docs/theming/dark-mode
 */

// import '@ionic/core/css/palettes/dark.always.css';
// import '@ionic/core/css/palettes/dark.class.css';
import '@ionic/core/css/palettes/dark.system.css';

/* Theme variables */
import './theme/variables.css';

/**
 * On Ionicons 7.2+ this icon
 * gets mapped to a "heart" key.
 * Alternatively, developers can do:
 * addIcons({ 'heart': heart });
 */
addIcons({ heart });

defineCustomElements();

Angular

src/app/example.component.html

<ion-button>Default</ion-button>
<ion-button shape="round">Round</ion-button>
<ion-button>
  <ion-icon slot="icon-only" name="heart"></ion-icon>
</ion-button>
<ion-button shape="round">
  <ion-icon slot="icon-only" name="heart"></ion-icon>
</ion-button>

src/app/example.component.ts

import { Component } from '@angular/core';
import { IonButton, IonIcon } from '@ionic/angular';

import { addIcons } from 'ionicons';
import { heart } from 'ionicons/icons';

@Component({
  selector: 'app-example',
  templateUrl: 'example.component.html',
  styleUrls: ['example.component.css'],
  imports: [IonButton, IonIcon],
})
export class ExampleComponent {
  constructor() {
    /**
     * Any icons you want to use in your application
     * can be registered in app.component.ts and then
     * referenced by name anywhere in your application.
     */
    addIcons({ heart });
  }
}

React

import React from 'react';
import { IonButton, IonIcon } from '@ionic/react';
import { heart } from 'ionicons/icons';

function Example() {
  return (
    <>
      <IonButton>Default</IonButton>
      <IonButton shape="round">Round</IonButton>
      <IonButton>
        <IonIcon slot="icon-only" icon={heart}></IonIcon>
      </IonButton>
      <IonButton shape="round">
        <IonIcon slot="icon-only" icon={heart}></IonIcon>
      </IonButton>
    </>
  );
}
export default Example;

Vue

<template>
  <ion-button>Default</ion-button>
  <ion-button shape="round">Round</ion-button>
  <ion-button>
    <ion-icon slot="icon-only" :icon="heart"></ion-icon>
  </ion-button>
  <ion-button shape="round">
    <ion-icon slot="icon-only" :icon="heart"></ion-icon>
  </ion-button>
</template>

<script setup lang="ts">
  import { IonButton, IonIcon } from '@ionic/vue';
  import { heart } from 'ionicons/icons';
</script>

Fill

이 프로퍼티는 버튼의 배경색과 테두리 색을 결정해요. 기본적으로 버튼은 탄탄한(solid) 배경을 가지지만, toolbar 안에 있으면 투명한 배경을 가져요.

JavaScript

<ion-button>Default</ion-button>
<ion-button fill="clear">Clear</ion-button>
<ion-button fill="outline">Outline</ion-button>
<ion-button fill="solid">Solid</ion-button>

Angular

src/app/example.component.html

<ion-button>Default</ion-button>
<ion-button fill="clear">Clear</ion-button>
<ion-button fill="outline">Outline</ion-button>
<ion-button fill="solid">Solid</ion-button>

src/app/example.component.ts

import { Component } from '@angular/core';
import { IonButton } from '@ionic/angular';

@Component({
  selector: 'app-example',
  templateUrl: 'example.component.html',
  styleUrls: ['example.component.css'],
  imports: [IonButton],
})
export class ExampleComponent {}

React

import React from 'react';
import { IonButton } from '@ionic/react';

function Example() {
  return (
    <>
      <IonButton>Default</IonButton>
      <IonButton fill="clear">Clear</IonButton>
      <IonButton fill="outline">Outline</IonButton>
      <IonButton fill="solid">Solid</IonButton>
    </>
  );
}
export default Example;

Vue

<template>
  <ion-button>Default</ion-button>
  <ion-button fill="clear">Clear</ion-button>
  <ion-button fill="outline">Outline</ion-button>
  <ion-button fill="solid">Solid</ion-button>
</template>

<script setup lang="ts">
  import { IonButton } from '@ionic/vue';
</script>

Size

이 프로퍼티는 버튼의 크기를 지정해요. 설정하면 버튼의 높이와 패딩이 바뀌어요.

JavaScript

<ion-button size="small">Small</ion-button>
<ion-button size="default">Default</ion-button>
<ion-button size="large">Large</ion-button>

Angular

src/app/example.component.html

<ion-button size="small">Small</ion-button>
<ion-button size="default">Default</ion-button>
<ion-button size="large">Large</ion-button>

src/app/example.component.ts

import { Component } from '@angular/core';
import { IonButton } from '@ionic/angular';

@Component({
  selector: 'app-example',
  templateUrl: 'example.component.html',
  styleUrls: ['example.component.css'],
  imports: [IonButton],
})
export class ExampleComponent {}

React

import React from 'react';
import { IonButton } from '@ionic/react';

function Example() {
  return (
    <>
      <IonButton size="small">Small</IonButton>
      <IonButton size="default">Default</IonButton>
      <IonButton size="large">Large</IonButton>
    </>
  );
}
export default Example;

Vue

<template>
  <ion-button size="small">Small</ion-button>
  <ion-button size="default">Default</ion-button>
  <ion-button size="large">Large</ion-button>
</template>

<script setup lang="ts">
  import { IonButton } from '@ionic/vue';
</script>

Icons

JavaScript

index.html

<ion-button size="small">
  <ion-icon slot="icon-only" ios="logo-apple" md="settings-sharp"></ion-icon>
</ion-button>

<ion-button>
  <ion-icon slot="icon-only" ios="logo-apple" md="settings-sharp"></ion-icon>
</ion-button>

<ion-button size="large">
  <ion-icon slot="icon-only" ios="logo-apple" md="settings-sharp"></ion-icon>
</ion-button>

<ion-button size="small">
  <ion-icon slot="start" name="star"></ion-icon>
  Left Icon
</ion-button>

<ion-button>
  <ion-icon slot="start" name="star"></ion-icon>
  Left Icon
</ion-button>

<ion-button size="large">
  <ion-icon slot="start" name="star"></ion-icon>
  Left Icon
</ion-button>

<ion-button size="small">
  Right Icon
  <ion-icon slot="end" name="heart"></ion-icon>
</ion-button>

<ion-button>
  Right Icon
  <ion-icon slot="end" name="heart"></ion-icon>
</ion-button>

<ion-button size="large">
  Right Icon
  <ion-icon slot="end" name="heart"></ion-icon>
</ion-button>

index.ts

import { defineCustomElements } from '@ionic/core/loader';

import { addIcons } from 'ionicons';
import { heart, logoApple, settingsSharp, star } from 'ionicons/icons';

/* Core CSS required for Ionic components to work properly */
import '@ionic/core/css/core.css';

/* Basic CSS for apps built with Ionic */
import '@ionic/core/css/normalize.css';
import '@ionic/core/css/structure.css';
import '@ionic/core/css/typography.css';

/* Optional CSS utils that can be commented out */
import '@ionic/core/css/padding.css';
import '@ionic/core/css/float-elements.css';
import '@ionic/core/css/text-alignment.css';
import '@ionic/core/css/text-transformation.css';
import '@ionic/core/css/flex-utils.css';
import '@ionic/core/css/display.css';

/**
 * Ionic Dark Palette
 * -----------------------------------------------------
 * For more information, please see:
 * https://ionicframework.com/docs/theming/dark-mode
 */

// import '@ionic/core/css/palettes/dark.always.css';
// import '@ionic/core/css/palettes/dark.class.css';
import '@ionic/core/css/palettes/dark.system.css';

/* Theme variables */
import './theme/variables.css';

/**
 * On Ionicons 7.2+ these icons
 * get mapped to a kebab-case key.
 * Alternatively, developers can do:
 * addIcons({ 'heart': heart, 'logo-apple': logoApple, 'settings-sharp': settingsSharp, 'star': star });
 */
addIcons({ heart, logoApple, settingsSharp, star });

defineCustomElements();

Angular

src/app/example.component.html

<ion-button size="small">
  <ion-icon slot="icon-only" ios="logo-apple" md="settings-sharp"></ion-icon>
</ion-button>

<ion-button>
  <ion-icon slot="icon-only" ios="logo-apple" md="settings-sharp"></ion-icon>
</ion-button>

<ion-button size="large">
  <ion-icon slot="icon-only" ios="logo-apple" md="settings-sharp"></ion-icon>
</ion-button>

<ion-button size="small">
  <ion-icon slot="start" name="star"></ion-icon>
  Left Icon
</ion-button>

<ion-button>
  <ion-icon slot="start" name="star"></ion-icon>
  Left Icon
</ion-button>

<ion-button size="large">
  <ion-icon slot="start" name="star"></ion-icon>
  Left Icon
</ion-button>

<ion-button size="small">
  Right Icon
  <ion-icon slot="end" name="heart"></ion-icon>
</ion-button>

<ion-button>
  Right Icon
  <ion-icon slot="end" name="heart"></ion-icon>
</ion-button>

<ion-button size="large">
  Right Icon
  <ion-icon slot="end" name="heart"></ion-icon>
</ion-button>

src/app/example.component.ts

import { Component } from '@angular/core';
import { IonButton, IonIcon } from '@ionic/angular';

import { addIcons } from 'ionicons';
import { heart, logoApple, settingsSharp, star } from 'ionicons/icons';

@Component({
  selector: 'app-example',
  templateUrl: 'example.component.html',
  styleUrls: ['example.component.css'],
  imports: [IonButton, IonIcon],
})
export class ExampleComponent {
  constructor() {
    /**
     * Any icons you want to use in your application
     * can be registered in app.component.ts and then
     * referenced by name anywhere in your application.
     */
    addIcons({ heart, logoApple, settingsSharp, star });
  }
}

React

import React from 'react';
import { IonButton, IonIcon } from '@ionic/react';
import { heart, logoApple, settingsSharp, star } from 'ionicons/icons';

function Example() {
  return (
    <>
      <IonButton size="small">
        <IonIcon slot="icon-only" ios={logoApple} md={settingsSharp}></IonIcon>
      </IonButton>

      <IonButton>
        <IonIcon slot="icon-only" ios={logoApple} md={settingsSharp}></IonIcon>
      </IonButton>

      <IonButton size="large">
        <IonIcon slot="icon-only" ios={logoApple} md={settingsSharp}></IonIcon>
      </IonButton>

      <IonButton size="small">
        <IonIcon slot="start" icon={star}></IonIcon>
        Left Icon
      </IonButton>

      <IonButton>
        <IonIcon slot="start" icon={star}></IonIcon>
        Left Icon
      </IonButton>

      <IonButton size="large">
        <IonIcon slot="start" icon={star}></IonIcon>
        Left Icon
      </IonButton>

      <IonButton size="small">
        Right Icon
        <IonIcon slot="end" icon={heart}></IonIcon>
      </IonButton>

      <IonButton>
        Right Icon
        <IonIcon slot="end" icon={heart}></IonIcon>
      </IonButton>

      <IonButton size="large">
        Right Icon
        <IonIcon slot="end" icon={heart}></IonIcon>
      </IonButton>
    </>
  );
}
export default Example;

Vue

<template>
  <ion-button size="small">
    <ion-icon slot="icon-only" :ios="logoApple" :md="settingsSharp"></ion-icon>
  </ion-button>

  <ion-button>
    <ion-icon slot="icon-only" :ios="logoApple" :md="settingsSharp"></ion-icon>
  </ion-button>

  <ion-button size="large">
    <ion-icon slot="icon-only" :ios="logoApple" :md="settingsSharp"></ion-icon>
  </ion-button>

  <ion-button size="small">
    <ion-icon slot="start" :icon="star"></ion-icon>
    Left Icon
  </ion-button>

  <ion-button>
    <ion-icon slot="start" :icon="star"></ion-icon>
    Left Icon
  </ion-button>

  <ion-button size="large">
    <ion-icon slot="start" :icon="star"></ion-icon>
    Left Icon
  </ion-button>

  <ion-button size="small">
    Right Icon
    <ion-icon slot="end" :icon="heart"></ion-icon>
  </ion-button>

  <ion-button>
    Right Icon
    <ion-icon slot="end" :icon="heart"></ion-icon>
  </ion-button>

  <ion-button size="large">
    Right Icon
    <ion-icon slot="end" :icon="heart"></ion-icon>
  </ion-button>
</template>

<script setup lang="ts">
  import { IonButton, IonIcon } from '@ionic/vue';
  import { heart, logoApple, settingsSharp, star } from 'ionicons/icons';
</script>

Theming

Colors

JavaScript

<ion-button>Default</ion-button>
<ion-button color="primary">Primary</ion-button>
<ion-button color="secondary">Secondary</ion-button>
<ion-button color="tertiary">Tertiary</ion-button>
<ion-button color="success">Success</ion-button>
<ion-button color="warning">Warning</ion-button>
<ion-button color="danger">Danger</ion-button>
<ion-button color="light">Light</ion-button>
<ion-button color="medium">Medium</ion-button>
<ion-button color="dark">Dark</ion-button>

Angular

src/app/example.component.html

<ion-button>Default</ion-button>
<ion-button color="primary">Primary</ion-button>
<ion-button color="secondary">Secondary</ion-button>
<ion-button color="tertiary">Tertiary</ion-button>
<ion-button color="success">Success</ion-button>
<ion-button color="warning">Warning</ion-button>
<ion-button color="danger">Danger</ion-button>
<ion-button color="light">Light</ion-button>
<ion-button color="medium">Medium</ion-button>
<ion-button color="dark">Dark</ion-button>

src/app/example.component.ts

import { Component } from '@angular/core';
import { IonButton } from '@ionic/angular';

@Component({
  selector: 'app-example',
  templateUrl: 'example.component.html',
  styleUrls: ['example.component.css'],
  imports: [IonButton],
})
export class ExampleComponent {}

React

import React from 'react';
import { IonButton } from '@ionic/react';

function Example() {
  return (
    <>
      <IonButton>Default</IonButton>
      <IonButton color="primary">Primary</IonButton>
      <IonButton color="secondary">Secondary</IonButton>
      <IonButton color="tertiary">Tertiary</IonButton>
      <IonButton color="success">Success</IonButton>
      <IonButton color="warning">Warning</IonButton>
      <IonButton color="danger">Danger</IonButton>
      <IonButton color="light">Light</IonButton>
      <IonButton color="medium">Medium</IonButton>
      <IonButton color="dark">Dark</IonButton>
    </>
  );
}
export default Example;

Vue

<template>
  <ion-button>Default</ion-button>
  <ion-button color="primary">Primary</ion-button>
  <ion-button color="secondary">Secondary</ion-button>
  <ion-button color="tertiary">Tertiary</ion-button>
  <ion-button color="success">Success</ion-button>
  <ion-button color="warning">Warning</ion-button>
  <ion-button color="danger">Danger</ion-button>
  <ion-button color="light">Light</ion-button>
  <ion-button color="medium">Medium</ion-button>
  <ion-button color="dark">Dark</ion-button>
</template>

<script setup lang="ts">
  import { IonButton } from '@ionic/vue';
</script>

CSS Custom Properties

JavaScript

<style>
  ion-button {
    --background: #93e9be;
    --background-hover: #9ce0be;
    --background-activated: #88f4be;
    --background-focused: #88f4be;

    --color: blue;

    --border-radius: 0;
    --border-color: #000;
    --border-style: solid;
    --border-width: 1px;

    --box-shadow: 0 2px 6px 0 rgb(0, 0, 0, 0.25);

    --ripple-color: deeppink;

    --padding-top: 10px;
    --padding-bottom: 10px;
  }
</style>

<ion-button>Custom Button</ion-button>

Angular

src/app/example.component.html

<ion-button>Custom Button</ion-button>

src/app/example.component.css

ion-button {
  --background: #93e9be;
  --background-hover: #9ce0be;
  --background-activated: #88f4be;
  --background-focused: #88f4be;

  --color: blue;

  --border-radius: 0;
  --border-color: #000;
  --border-style: solid;
  --border-width: 1px;

  --box-shadow: 0 2px 6px 0 rgb(0, 0, 0, 0.25);

  --ripple-color: deeppink;

  --padding-top: 10px;
  --padding-bottom: 10px;
}

src/app/example.component.ts

import { Component } from '@angular/core';
import { IonButton } from '@ionic/angular';

@Component({
  selector: 'app-example',
  templateUrl: 'example.component.html',
  styleUrls: ['example.component.css'],
  imports: [IonButton],
})
export class ExampleComponent {}

React

src/main.tsx

import React from 'react';
import { IonButton } from '@ionic/react';

import './main.css';

function Example() {
  return <IonButton>Custom Button</IonButton>;
}
export default Example;

src/main.css

ion-button {
  --background: #93e9be;
  --background-hover: #9ce0be;
  --background-activated: #88f4be;
  --background-focused: #88f4be;

  --color: blue;

  --border-radius: 0;
  --border-color: #000;
  --border-style: solid;
  --border-width: 1px;

  --box-shadow: 0 2px 6px 0 rgb(0, 0, 0, 0.25);

  --ripple-color: deeppink;

  --padding-top: 10px;
  --padding-bottom: 10px;
}

Vue

<template>
  <ion-button>Custom Button</ion-button>
</template>

<script setup lang="ts">
  import { IonButton } from '@ionic/vue';
</script>

<style scoped>
  ion-button {
    --background: #93e9be;
    --background-hover: #9ce0be;
    --background-activated: #88f4be;
    --background-focused: #88f4be;

    --color: blue;

    --border-radius: 0;
    --border-color: #000;
    --border-style: solid;
    --border-width: 1px;

    --box-shadow: 0 2px 6px 0 rgb(0, 0, 0, 0.25);

    --ripple-color: deeppink;

    --padding-top: 10px;
    --padding-bottom: 10px;
  }
</style>

Accessibility

버튼은 접근성을 고려해 만들어졌지만, 콘텐츠에 따라 몇 가지 조정이 필요할 수 있어요. 버튼 컴포넌트는 네이티브 button 요소를 렌더링하므로, 네이티브 버튼이 제공하는 기능을 그대로 활용할 수 있어요.

Overflowing Text Content

버튼의 텍스트 콘텐츠가 컨테이너를 넘치는 경우가 많아요. 이런 경우에는 버튼 안에서 텍스트를 감싸서(wrap) 모든 텍스트를 읽을 수 있게 하는 것이 좋아요. 버튼 컴포넌트는 추가된 텍스트 줄에 맞춰 높이를 자동으로 조절해요.

버튼 텍스트는 너무 길어서 맞지 않을 때 자동으로 다음 줄로 넘어가지 않아요. 텍스트를 줄바꿈하게 하려면 ion-text-wrap 클래스를 추가하면 돼요. 이 클래스는 white-space 프로퍼티를 "normal"로 설정해요. 이 동작은 향후 주요 릴리스에서 기본값이 될 예정이에요.

Info

아래 버튼의 max-width 스타일은 데모용으로만 설정된 거예요. 텍스트 줄바꿈은 동적인 버튼 너비에서도 정상 동작해요.

JavaScript

<ion-button>Default</ion-button>
<ion-button class="ion-text-wrap" style="max-width: 400px"
  >This is the button that never ends it just goes on and on and on and on and on and on and on and on my
  friends</ion-button
>

Angular

src/app/example.component.html

<ion-button>Default</ion-button>
<ion-button class="ion-text-wrap" style="max-width: 400px"
  >This is the button that never ends it just goes on and on and on and on and on and on and on and on my
  friends</ion-button
>

src/app/example.component.ts

import { Component } from '@angular/core';
import { IonButton } from '@ionic/angular';

@Component({
  selector: 'app-example',
  templateUrl: 'example.component.html',
  styleUrls: ['example.component.css'],
  imports: [IonButton],
})
export class ExampleComponent {}

React

import React from 'react';
import { IonButton } from '@ionic/react';

function Example() {
  return (
    <>
      <IonButton>Default</IonButton>
      <IonButton className="ion-text-wrap" style={{ maxWidth: '400px' }}>
        This is the button that never ends it just goes on and on and on and on and on and on and on and on my friends
      </IonButton>
    </>
  );
}
export default Example;

Vue

<template>
  <ion-button>Default</ion-button>
  <ion-button class="ion-text-wrap" style="max-width: 400px"
    >This is the button that never ends it just goes on and on and on and on and on and on and on and on my
    friends</ion-button
  >
</template>

<script setup lang="ts">
  import { IonButton } from '@ionic/vue';
</script>

Properties

buttonType

Description: The type of button.

Attribute: button-type

Type: string

Default: 'button'

color

Description: The color to use from your application's color palette. Default options are: "primary", "secondary", "tertiary", "success", "warning", "danger", "light", "medium", and "dark". For more information on colors, see theming.

Attribute: color

Type: "danger" | "dark" | "light" | "medium" | "primary" | "secondary" | "success" | "tertiary" | "warning" | string | undefined

Default: undefined

disabled

Description: If true, the user cannot interact with the button.

Attribute: disabled

Type: boolean

Default: false

download

Description: This attribute instructs browsers to download a URL instead of navigating to it, so the user will be prompted to save it as a local file. If the attribute has a value, it is used as the pre-filled file name in the Save prompt (the user can still change the file name if they want).

Attribute: download

Type: string | undefined

Default: undefined

expand

Description: Set to "block" for a full-width button or to "full" for a full-width button with square corners and no left or right borders.

Attribute: expand

Type: "block" | "full" | undefined

Default: undefined

fill

Description: Set to "clear" for a transparent button that resembles a flat button, to "outline" for a transparent button with a border, or to "solid" for a button with a filled background. The default fill is "solid" except inside of a toolbar, where the default is "clear".

Attribute: fill

Type: "clear" | "default" | "outline" | "solid" | undefined

Default: undefined

form

Description: The HTML form element or form element id. Used to submit a form when the button is not a child of the form. This is a virtual property that is set once during initialization and will not update if you change its value after the initial render.

Attribute: form

Type: HTMLFormElement | string | undefined

Default: undefined

href

Description: Contains a URL or a URL fragment that the hyperlink points to. If this property is set, an anchor tag will be rendered.

Attribute: href

Type: string | undefined

Default: undefined

mode

Description: The mode determines which platform styles to use. This is a virtual property that is set once during initialization and will not update if you change its value after the initial render.

Attribute: mode

Type: "ios" | "md"

Default: undefined

rel

Description: Specifies the relationship of the target object to the link object. The value is a space-separated list of link types.

Attribute: rel

Type: string | undefined

Default: undefined

routerAnimation

Description: When using a router, it specifies the transition animation when navigating to another page using href.

Attribute: undefined

Type: ((baseEl: any, opts?: any) => Animation) | undefined

Default: undefined

routerDirection

Description: When using a router, it specifies the transition direction when navigating to another page using href.

Attribute: router-direction

Type: "back" | "forward" | "root"

Default: 'forward'

shape

Description: Set to "round" for a button with more rounded corners.

Attribute: shape

Type: "round" | undefined

Default: undefined

size

Description: Set to "small" for a button with less height and padding, to "default" for a button with the default height and padding, or to "large" for a button with more height and padding. By default the size is unset, unless the button is inside of an item, where the size is "small" by default. Set the size to "default" inside of an item to make it a standard size button.

Attribute: size

Type: "default" | "large" | "small" | undefined

Default: undefined

strong

Description: If true, activates a button with a heavier font weight.

Attribute: strong

Type: boolean

Default: false

target

Description: Specifies where to display the linked URL. Only applies when an href is provided. Special keywords: "_blank", "_self", "_parent", "_top".

Attribute: target

Type: string | undefined

Default: undefined

type

Description: The type of the button.

Attribute: type

Type: "button" | "reset" | "submit"

Default: 'button'

Events

Name Description Bubbles
ionBlur Emitted when the button loses focus. true
ionFocus Emitted when the button has focus. true

Methods

No public methods available for this component.

CSS Shadow Parts

Name Description
native The native HTML button or anchor element that wraps all child elements.

CSS Custom Properties

iOS

Name Description
--background Background of the button
--background-activated Background of the button when pressed. Note: setting this will interfere with the Material Design ripple.
--background-activated-opacity Opacity of the button when pressed
--background-focused Background of the button when focused with the tab key
--background-focused-opacity Opacity of the button when focused with the tab key
--background-hover Background of the button on hover
--background-hover-opacity Opacity of the background on hover
--border-color Border color of the button
--border-radius Border radius of the button
--border-style Border style of the button
--border-width Border width of the button
--box-shadow Box shadow of the button
--color Text color of the button
--color-activated Text color of the button when pressed
--color-focused Text color of the button when focused with the tab key
--color-hover Text color of the button when hover
--opacity Opacity of the button
--padding-bottom Bottom padding of the button
--padding-end Right padding if direction is left-to-right, and left padding if direction is right-to-left of the button
--padding-start Left padding if direction is left-to-right, and right padding if direction is right-to-left of the button
--padding-top Top padding of the button
--ripple-color Color of the button ripple effect
--transition Transition of the button

MD

Name Description
--background Background of the button
--background-activated Background of the button when pressed. Note: setting this will interfere with the Material Design ripple.
--background-activated-opacity Opacity of the button when pressed
--background-focused Background of the button when focused with the tab key
--background-focused-opacity Opacity of the button when focused with the tab key
--background-hover Background of the button on hover
--background-hover-opacity Opacity of the background on hover
--border-color Border color of the button
--border-radius Border radius of the button
--border-style Border style of the button
--border-width Border width of the button
--box-shadow Box shadow of the button
--color Text color of the button
--color-activated Text color of the button when pressed
--color-focused Text color of the button when focused with the tab key
--color-hover Text color of the button when hover
--opacity Opacity of the button
--padding-bottom Bottom padding of the button
--padding-end Right padding if direction is left-to-right, and left padding if direction is right-to-left of the button
--padding-start Left padding if direction is left-to-right, and right padding if direction is right-to-left of the button
--padding-top Top padding of the button
--ripple-color Color of the button ripple effect
--transition Transition of the button

Slots

Name Description
Content is placed between the named slots if provided without a slot.
end Content is placed to the right of the button text in LTR, and to the left in RTL.
icon-only Should be used on an icon in a button that has no text.
start Content is placed to the left of the button text in LTR, and to the right in RTL.

더 알아보기 (Learn more)

ion-button는 클릭 가능한 요소를 만들어 주는 가장 기본적인 컴포넌트예요. expand, shape, fill, size로 모양을 바꾸고 color와 다양한 --* CSS 변수로 스타일을 조정할 수 있어요. 여러 버튼을 toolbar 안에서 한곳에 모으려면 ion-buttons 문서를 참고하세요.