Chips / Tags - 图1

Chip React Component

Chips (Tags) React component represent complex entities in small blocks, such as a contact. They can contain a photo, short title string, and brief information

Chip Components

There are following components included:

  • **Chip** / **F7Chip**

Chip Properties

PropTypeDefaultDescription
<Chip> properties
textstringChip label text
mediastringText content of chip media
mediaBgColorstringChip media element background color. One of the default colors
mediaTextColorstringChip media element text color. One of the default colors
deleteablebooleanfalseDefines whether the Chip has additional “delete” button or not
outlinebooleanfalseMakes Card outline

Chip Events

EventDescription
<Chip> events
clickEvent will be triggered on Chip click
deleteEvent will be triggered on Chip delete button click

Chip Slots

Chip React component has additional slots for custom elements:

  • **text** - element will be inserted in place of chip text label
  • **media** - element will be inserted in the chip’s media element

Examples

  1. export default class extends React.Component {
  2. constructor() {
  3. super();
  4. this.deleteChipBound = this.deleteChip.bind(this);
  5. }
  6. render() {
  7. return (
  8. <Page>
  9. <Navbar title="Chips"></Navbar>
  10. <BlockTitle>Chips With Text</BlockTitle>
  11. <Block strong>
  12. <Chip text="Example Chip" />
  13. <Chip text="Another Chip" />
  14. <Chip text="One More Chip" />
  15. <Chip text="Fourth Chip" />
  16. <Chip text="Last One" />
  17. </Block>
  18. <BlockTitle>Outline Chips</BlockTitle>
  19. <Block strong>
  20. <Chip outline text="Example Chip" />
  21. <Chip outline text="Another Chip" />
  22. <Chip outline text="One More Chip" />
  23. <Chip outline text="Fourth Chip" />
  24. <Chip outline text="Last One" />
  25. </Block>
  26. <BlockTitle>Icon Chips</BlockTitle>
  27. <Block strong>
  28. <Chip text="Add Contact" mediaBgColor="blue">
  29. <Icon slot="media" ios="f7:add_round" md="material:add_circle"></Icon>
  30. </Chip>
  31. <Chip text="London" mediaBgColor="green">
  32. <Icon slot="media" ios="f7:compass" md="material:location_on"></Icon>
  33. </Chip>
  34. <Chip text="John Doe" mediaBgColor="red">
  35. <Icon slot="media" ios="f7:person" md="material:person"></Icon>
  36. </Chip>
  37. </Block>
  38. <BlockTitle>Contact Chips</BlockTitle>
  39. <Block strong>
  40. <Chip text="Jane Doe">
  41. <img slot="media" src="http://lorempixel.com/100/100/people/9/" />
  42. </Chip>
  43. <Chip text="John Doe">
  44. <img slot="media" src="http://lorempixel.com/100/100/people/3/" />
  45. </Chip>
  46. <Chip text="Adam Smith">
  47. <img slot="media" src="http://lorempixel.com/100/100/people/7/" />
  48. </Chip>
  49. <Chip text="Jennifer" mediaBgColor="pink" media="J" />
  50. <Chip text="Chris" mediaBgColor="yellow" mediaTextColor="black" media="C" />
  51. <Chip text="Kate" mediaBgColor="red" media="K" />
  52. </Block>
  53. <BlockTitle>Deletable Chips / Tags</BlockTitle>
  54. <Block strong>
  55. <Chip text="Example Chip" deleteable onClick={ this.deleteChipBound } />
  56. <Chip text="Chris" media="C" mediaBgColor="orange" textColor="black" deleteable onClick={ this.deleteChipBound } />
  57. <Chip text="Jane Doe" deleteable onClick={ this.deleteChipBound }>
  58. <img slot="media" src="http://lorempixel.com/100/100/people/9/"/>
  59. </Chip>
  60. <Chip text="One More Chip" deleteable onClick={ this.deleteChipBound } />
  61. <Chip text="Jennifer" mediaBgColor="pink" media="J" deleteable onClick={ this.deleteChipBound } />
  62. <Chip text="Adam Smith" deleteable onClick={ this.deleteChipBound }>
  63. <img slot="media" src="http://lorempixel.com/100/100/people/7/"/>
  64. </Chip>
  65. </Block>
  66. <BlockTitle>Color Chips</BlockTitle>
  67. <Block strong>
  68. <Chip text="Red Chip" color="red" />
  69. <Chip text="Green Chip" color="green" />
  70. <Chip text="Blue Chip" color="blue" />
  71. <Chip text="Orange Chip" color="orange" />
  72. <Chip text="Pink Chip" color="pink" />
  73. <Chip outline text="Red Chip" color="red" />
  74. <Chip outline text="Green Chip" color="green" />
  75. <Chip outline text="Blue Chip" color="blue" />
  76. <Chip outline text="Orange Chip" color="orange" />
  77. <Chip outline text="Pink Chip" color="pink" />
  78. </Block>
  79. </Page>
  80. )
  81. }
  82. deleteChip(e) {
  83. const $$ = this.$$;
  84. const app = this.$f7;
  85. const target = e.target;
  86. app.dialog.confirm('Do you want to delete this tiny demo Chip?', () => {
  87. $$(target).parents('.chip').remove();
  88. });
  89. }
  90. }