Class: Primer::Alpha::FormButton

Inherits:
Component
  • Object
show all
Defined in:
app/components/primer/alpha/form_button.rb

Overview

A button input rendered using the HTML ‘<button type=“button”>` tag.

This component wraps the Primer button component and supports the same slots and arguments.

Constant Summary

Constants inherited from Component

Component::INVALID_ARIA_LABEL_TAGS

Constants included from Status::Dsl

Status::Dsl::STATUSES

Constants included from ViewHelper

ViewHelper::HELPERS

Constants included from TestSelectorHelper

TestSelectorHelper::TEST_SELECTOR_TAG

Constants included from FetchOrFallbackHelper

FetchOrFallbackHelper::InvalidValueError

Constants included from Primer::AttributesHelper

Primer::AttributesHelper::PLURAL_ARIA_ATTRIBUTES, Primer::AttributesHelper::PLURAL_DATA_ATTRIBUTES

Instance Method Summary collapse

Methods inherited from Component

deprecated?, generate_id

Methods included from JoinStyleArgumentsHelper

#join_style_arguments

Methods included from TestSelectorHelper

#add_test_selector

Methods included from FetchOrFallbackHelper

#fetch_or_fallback, #fetch_or_fallback_boolean, #silence_deprecations?

Methods included from ClassNameHelper

#class_names

Methods included from Primer::AttributesHelper

#aria, #data, #merge_aria, #merge_data, #merge_prefixed_attribute_hashes

Constructor Details

#initializeObject

Parameters:

  • name (String)

    Value for the HTML name attribute.

  • id (String)

    Value for the HTML id attribute.

  • class (String)

    CSS classes to include in the input’s HTML ‘class` attribute. Exists for compatibility with Rails form builders.

  • classes (Array)

    CSS classes to include in the input’s HTML ‘class` attribute. Combined with the `:class` argument. The list may contain strings, hashes, or `nil` values, and is automatically cleaned up by Primer’s [‘class_name` helper](github.com/primer/view_components/blob/c9cb95c98fee3e2e27f4a10683f555e22285e7f1/app/lib/primer/class_name_helper.rb) (`nils`, falsy entries, and blank strings are ignored).

  • label (String)

    Label text displayed above the input.

  • aria (Hash)

    Key/value pairs that represent Aria attributes and their values. Eg. ‘aria: { current: true }` becomes `aria-current=“true”`.

  • data (Hash)

    Key/value pairs that represent data attributes and their values. Eg. ‘data: { foo: “bar” }` becomes `data-foo=“bar”`.

  • system_arguments (Hash)

    A hash of attributes passed to the underlying Rails builder methods. These options may mean something special depending on the type of input, otherwise they are emitted as HTML attributes. See the [Rails documentation](guides.rubyonrails.org/form_helpers.html) for more information. In addition, the usual Primer utility arguments are accepted in system arguments. For example, passing ‘mt: 2` will add the `mt-2` class to the input. See the Primer system arguments docs for details.



# File 'app/components/primer/alpha/form_button.rb', line 20