Chip Svelte Component
Chips (Tags) Svelte 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
Chip Properties
Prop | Type | Default | Description |
---|---|---|---|
<Chip> properties | |||
text | string | Chip label text | |
media | string | Text content of chip media | |
mediaBgColor | string | Chip media element background color. One of the default colors | |
mediaTextColor | string | Chip media element text color. One of the default colors | |
deleteable | boolean | false | Defines whether the Chip has additional “delete” button or not |
outline | boolean | false | Makes Card outline |
<Chip> icon related properties | |||
iconSize | string number | Icon size in px | |
iconColor | string | Icon color. One of the default colors | |
icon | string | Custom icon class | |
iconF7 | string | Name of F7 Icons font icon | |
iconMaterial | string | Name of Material Icons font icon | |
iconIos | string | Icon to be used in case of iOS theme is used. Consists of icon family and icon name divided by colon, e.g. f7:home | |
iconMd | string | Icon to be used in case of MD theme is used. Consists of icon family and icon name divided by colon, e.g. material:home | |
iconAurora | string | Icon to be used in case of Aurora theme is used. Consists of icon family and icon name divided by colon, e.g. f7:home |
Chip Events
Event | Description |
---|---|
<Chip> events | |
click | Event will be triggered on Chip click |
delete | Event will be triggered on Chip delete button click |
Chip Slots
Chip Svelte component has additional slots for custom elements:
text
- element will be inserted in place of chip text labelmedia
- element will be inserted in the chip’s media element
Examples
<Page>
<Navbar title="Chips"></Navbar>
<BlockTitle>Chips With Text</BlockTitle>
<Block strong>
<Chip text="Example Chip" />
<Chip text="Another Chip" />
<Chip text="One More Chip" />
<Chip text="Fourth Chip" />
<Chip text="Last One" />
</Block>
<BlockTitle>Outline Chips</BlockTitle>
<Block strong>
<Chip outline text="Example Chip" />
<Chip outline text="Another Chip" />
<Chip outline text="One More Chip" />
<Chip outline text="Fourth Chip" />
<Chip outline text="Last One" />
</Block>
<BlockTitle>Icon Chips</BlockTitle>
<Block strong>
<Chip text="Add Contact" mediaBgColor="blue" iconIos="f7:plus_circle" iconAurora="f7:plus_circle" iconMd="material:add_circle" />
<Chip text="London" mediaBgColor="green" iconIos="f7:compass" iconAurora="f7:compass" iconMd="material:location_on" />
<Chip text="John Doe" mediaBgColor="red" iconIos="f7:person" iconAurora="f7:person" iconMd="material:person" />
</Block>
<BlockTitle>Contact Chips</BlockTitle>
<Block strong>
<Chip text="Jane Doe">
<img slot="media" src="https://cdn.framework7.io/placeholder/people-100x100-9.jpg" />
</Chip>
<Chip text="John Doe">
<img slot="media" src="https://cdn.framework7.io/placeholder/people-100x100-3.jpg" />
</Chip>
<Chip text="Adam Smith">
<img slot="media" src="https://cdn.framework7.io/placeholder/people-100x100-7.jpg" />
</Chip>
<Chip text="Jennifer" mediaBgColor="pink" media="J" />
<Chip text="Chris" mediaBgColor="yellow" mediaTextColor="black" media="C" />
<Chip text="Kate" mediaBgColor="red" media="K" />
</Block>
<BlockTitle>Deletable Chips / Tags</BlockTitle>
<Block strong>
<Chip text="Example Chip" deleteable onDelete={deleteChip} />
<Chip text="Chris" media="C" mediaBgColor="orange" textColor="black" deleteable onDelete={deleteChip} />
<Chip text="Jane Doe" deleteable onDelete={deleteChip}>
<img slot="media" src="https://cdn.framework7.io/placeholder/people-100x100-9.jpg"/>
</Chip>
<Chip text="One More Chip" deleteable onDelete={deleteChip} />
<Chip text="Jennifer" mediaBgColor="pink" media="J" deleteable onDelete={deleteChip} />
<Chip text="Adam Smith" deleteable onDelete={deleteChip}>
<img slot="media" src="https://cdn.framework7.io/placeholder/people-100x100-7.jpg"/>
</Chip>
</Block>
<BlockTitle>Color Chips</BlockTitle>
<Block strong>
<Chip text="Red Chip" color="red" />
<Chip text="Green Chip" color="green" />
<Chip text="Blue Chip" color="blue" />
<Chip text="Orange Chip" color="orange" />
<Chip text="Pink Chip" color="pink" />
<Chip outline text="Red Chip" color="red" />
<Chip outline text="Green Chip" color="green" />
<Chip outline text="Blue Chip" color="blue" />
<Chip outline text="Orange Chip" color="orange" />
<Chip outline text="Pink Chip" color="pink" />
</Block>
</Page>
<script>
import {f7, Page, Navbar, BlockTitle, Block, Chip, Icon} from 'framework7-svelte';
function deleteChip(e) {
const target = e.target;
f7.dialog.confirm('Do you want to delete this tiny demo Chip?', () => {
f7.$(target).parents('.chip').remove();
});
}
</script>
当前内容版权归 Framework7 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 Framework7 .