FieldsetFieldset is a grouping component with the optional content toggle feature.
Documentation
Import
import {FieldsetModule} from 'primeng/fieldset';
Getting Started
Fieldset is defined with p-fieldset element.
<p-fieldset legend="Header">
Content
</p-fieldset>
Toggleable
Content of the fieldset can be expanded and collapsed using toggleable option, default state is defined with collapsed option.
<p-fieldset legend="Header" [toggleable]="true">
Content
</p-fieldset>
Custom Legend
Legend content can be customized with p-header component.
<p-fieldset>
<p-header>Custom Legend Content</p-header>
Content
</p-fieldset>
Animation Configuration
Transition of toggle animation can be customized using the transitionOptions property with a default value as 400ms cubic-bezier(0.86, 0, 0.07, 1), example below disables the animation altogether.
<p-fieldset [transitionOptions]="'0ms'">
</p-fieldset>
Properties
Name | Type | Default | Description |
---|---|---|---|
legend | string | null | Header text of the fieldset. |
toggleable | boolean | false | When specified, content can toggled by clicking the legend. |
collapsed | boolean | false | Defines the default visibility state of the content. |
style | string | null | Inline style of the fieldset. |
styleClass | string | null | Style class of the fieldset. |
transitionOptions | string | 400ms cubic-bezier(0.86, 0, 0.07, 1) | Transition options of the animation. |
Events
Name | Parameters | Description |
---|---|---|
onBeforeToggle | event.originalEvent: browser event event.collapsed: state as a boolean | Callback to invoke before content toggle. |
onAfterToggle | event.originalEvent: browser event event.collapsed: state as a boolean | Callback to invoke after content toggle. |
Styling
Following is the list of structural style classes, for theming classes visit theming page.
Name | Element |
---|---|
ui-fieldset | Fieldset element |
ui-fieldset-toggleable | Toggleable fieldset element |
ui-fieldset-legend | Legend element. |
ui-fieldset-content | Content element. |
Dependencies
None.
Source
<p-fieldset legend="Godfather I">
The story begins as Don Vito Corleone, the head of a New York Mafia family, oversees his daughter's wedding.
His beloved son Michael has just come home from the war, but does not intend to become part of his father's business.
Through Michael's life the nature of the family business becomes clear. The business of the family is just like the head of the family,
kind and benevolent to those who give respect,
but given to ruthless violence whenever anything stands against the good of the family.
</p-fieldset>
<p-fieldset legend="Toggleable" [toggleable]="true">
The story begins as Don Vito Corleone, the head of a New York Mafia family, oversees his daughter's wedding.
His beloved son Michael has just come home from the war, but does not intend to become part of his father's business.
Through Michael's life the nature of the family business becomes clear. The business of the family is just like the head of the family,
kind and benevolent to those who give respect,
but given to ruthless violence whenever anything stands against the good of the family.
</p-fieldset>