FieldsetFieldset is a grouping component with the optional content toggle feature.

Fieldset - 图1

Documentation

Import

  1. import {FieldsetModule} from 'primeng/fieldset';
  2.  

Getting Started

Fieldset is defined with p-fieldset element.

  1. <p-fieldset legend="Header">
  2. Content
  3. </p-fieldset>
  4.  

Toggleable

Content of the fieldset can be expanded and collapsed using toggleable option, default state is defined with collapsed option.

  1. <p-fieldset legend="Header" [toggleable]="true">
  2. Content
  3. </p-fieldset>
  4.  

Custom Legend

Legend content can be customized with p-header component.

  1. <p-fieldset>
  2. <p-header>Custom Legend Content</p-header>
  3. Content
  4. </p-fieldset>
  5.  

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.

  1. <p-fieldset [transitionOptions]="'0ms'">
  2. </p-fieldset>
  3.  

Properties

NameTypeDefaultDescription
legendstringnullHeader text of the fieldset.
toggleablebooleanfalseWhen specified, content can toggled by clicking the legend.
collapsedbooleanfalseDefines the default visibility state of the content.
stylestringnullInline style of the fieldset.
styleClassstringnullStyle class of the fieldset.
transitionOptionsstring400ms cubic-bezier(0.86, 0, 0.07, 1)Transition options of the animation.

Events

NameParametersDescription
onBeforeToggleevent.originalEvent: browser event event.collapsed: state as a booleanCallback to invoke before content toggle.
onAfterToggleevent.originalEvent: browser event event.collapsed: state as a booleanCallback to invoke after content toggle.

Styling

Following is the list of structural style classes, for theming classes visit theming page.

NameElement
ui-fieldsetFieldset element
ui-fieldset-toggleableToggleable fieldset element
ui-fieldset-legendLegend element.
ui-fieldset-contentContent element.

Dependencies

None.

Source

View on GitHub

  1. <p-fieldset legend="Godfather I">
  2. The story begins as Don Vito Corleone, the head of a New York Mafia family, oversees his daughter's wedding.
  3. His beloved son Michael has just come home from the war, but does not intend to become part of his father's business.
  4. 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,
  5. kind and benevolent to those who give respect,
  6. but given to ruthless violence whenever anything stands against the good of the family.
  7. </p-fieldset>
  8. <p-fieldset legend="Toggleable" [toggleable]="true">
  9. The story begins as Don Vito Corleone, the head of a New York Mafia family, oversees his daughter's wedding.
  10. His beloved son Michael has just come home from the war, but does not intend to become part of his father's business.
  11. 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,
  12. kind and benevolent to those who give respect,
  13. but given to ruthless violence whenever anything stands against the good of the family.
  14. </p-fieldset>
  15.