Movatterモバイル変換


[0]ホーム

URL:


CoreUI Angular Logo
Framework:
Getting startedIntroductionSupport CoreUICustomizeSassOptionsCSS VariablesLayoutBreakpointsContainersGridColumnsGuttersFormsOverviewAutocompletePRODate PickerPRODate Range PickerPROForm ControlSelectMulti SelectPROChecks & RadiosPassword InputPRORangeRange SliderPRORatingPROStepperPROInput GroupFloating LabelsLayoutTime PickerPROValidationComponentsAccordionAlertAvatarBadgeBreadcrumbButtonButton GroupCalendarPROCalloutCardCarouselClose buttonCollapseDropdownFooterHeaderImageList GroupLoading ButtonPROModalNavNavbarOffcanvasPaginationPlaceholderPopoverProgressSmart PaginationPROSmart TablePROSidebarSpinnerTableTabsNewToastTooltipWidgetsIconsChartsTemplatesNewAdmin & DashboardDownloadInstallationCustomizeContentMigrationv4 → v5v3 → v4Angular version


DownloadHire UsGet CoreUI PRO
On this page

Angular Button Component

Angular button directive for actions in tables, forms, cards, and more. CoreUI for Angular provides various styles, states, and size. Ready to use and easy to customize.

Examples

CoreUI includes a bunch of predefined buttons components, each serving its own semantic purpose. Buttons show what action will happen when the user clicks or touches it. CoreUI buttons are used to initialize operations, both in the background or foreground of an experience.

Loading...
Loading...
Conveying meaning to assistive technologies

Using color to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies – such as screen readers. Ensure that information denoted by the color is either obvious from the content itself (e.g. the visible text), or is included through alternative means, such as additional text hidden with the.visually-hidden class.

Disable text wrapping

If you don't want the button text to wrap, you can add the.text-nowrap class to the<button>. In Sass, you can set$btn-white-space: nowrap to disable text wrapping for each button.

Button directive

ThecButton directive are designed for<button> ,<a> or<input> elements (though some browsers may apply a slightly different rendering).

If you're usingcButton directive as<a> elements that are used to trigger functionality ex. collapsing content, these links should be given arole="button" to adequately communicate their meaning to assistive technologies such as screen readers.

Link
Loading...
Loading...

Outline buttons

If you need a button, but without the strong background colors. Setvariant="outline" prop to remove all background colors.

Loading...
Loading...

Ghost buttons

If you need a ghost variant of button, setvariant="ghost" prop to remove all background colors.

Loading...
Loading...

Sizes

Larger or smaller buttons? Addsize="lg" orsize="sm" for additional sizes.

Loading...
Loading...
Loading...
Loading...

Shapes

Pill buttons

Loading...
Loading...

Square buttons

Loading...
Loading...

Disabled state

Add thedisabled boolean prop to any<button> component to make buttons look inactive. Disabled button haspointer-events: none applied to, disabling hover and active states from triggering.

Loading...
Loading...

Disabled buttons using the<a> component act a little different:

<a>s don't support thedisabled attribute, so CoreUI has to add.disabled class to make buttons look inactive. CoreUI also has to add to the disabled button componentaria-disabled="true" attribute to show the state of the component to assistive technologies.

Loading...
Loading...
Link functionality caveat

The.disabled class usespointer-events: none to try to disable the link functionality of<a>s, but that CSS property is not yet standardized. In addition, even in browsers that do supportpointer-events: none, keyboard navigation remains unaffected, meaning that sighted keyboard users and users of assistive technologies will still be able to activate these links. So to be safe, in addition toaria-disabled="true", also include atabindex="-1" attribute on these links to prevent them from receiving keyboard focus, and use custom JavaScript to disable their functionality altogether.

Block buttons

Create buttons that span the full width of a parent—by using utilities.

Loading...
Loading...

Here we create a responsive variation, starting with vertically stacked buttons until themd breakpoint, where.d-md-block replaces the.d-grid class, thus nullifying thegap-2 utility. Resize your browser to see them change.

Loading...
Loading...

You can adjust the width of your block buttons with grid column width classes. For example, for a half-width "block button", use.col-6. Center it horizontally with.mx-auto, too.

Loading...
Loading...

Additional utilities can be used to adjust the alignment of buttons when horizontal. Here we've taken our previous responsive example and added some flex utilities and a margin utility on the button to right align the buttons when they're no longer stacked.

Loading...
Loading...

API

Button Module

import { ButtonModule } from '@coreui/angular';@NgModule({ imports: [ButtonModule,]})export class AppModule(){}

cButton

directive


Inputs

namedescriptiontypedefault
activeToggle the active state for the componentbooleanfalse
disabledToggle the disabled state for the componentbooleanfalse
colorSets the color context of the component to one of CoreUI’s themed colors.string'primary'
shapeSelect the shape of the component.string
sizeSize the component small or large."" |"sm" |"lg"''
typeSpecifies the type of button. Always specify the type attribute for thebutton element. Different browsers may use different default types for thebutton element.ButtonType'button'
variantSet the button variant to an outlined button or a ghost button."ghost" |"outline"

CoreUI for Angular is Open Source UI Components Library for Angular.

Currently v5.5.17 Code licensed MIT, docs CC BY 3.0 .
CoreUI PRO requires acommercial license.


[8]ページ先頭

©2009-2025 Movatter.jp