Chip

Chips are compact elements that represent an input, attribute, or action.

https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/chips.png

Usage

MDChip:
    text: 'Coffee'
    color: .4470588235118, .1960787254902, 0, 1
    icon: 'coffee'
    on_release: app.callback_for_menu_items(self)

The user function takes two arguments - the object and the text of the chip:

def callback_for_menu_items(self, instance):
    print(instance)
https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/ordinary-chip.png

Use custom icon

MDChip:
    text: 'Kivy'
    icon: 'data/logo/kivy-icon-256.png'
https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/chip-custom-icon.png

Use without icon

MDChip:
    text: 'Without icon'
    icon: ''
https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/chip-without-icon.png

Chips with check

MDChip:
    text: 'Check with icon'
    icon: 'city'
    check: True
https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/chip-check-icon.gif

Choose chip

MDChooseChip:

    MDChip:
        text: 'Earth'
        icon: 'earth'
        selected_chip_color: .21176470535294, .098039627451, 1, 1

    MDChip:
        text: 'Face'
        icon: 'face'
        selected_chip_color: .21176470535294, .098039627451, 1, 1

    MDChip:
        text: 'Facebook'
        icon: 'facebook'
        selected_chip_color: .21176470535294, .098039627451, 1, 1
https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/chip-shoose-icon.gif

API - kivymd.uix.chip

class kivymd.uix.chip.MDChip(**kwargs)

This mixin class provides Button behavior. Please see the button behaviors module documentation for more information.

Events
on_press

Fired when the button is pressed.

on_release

Fired when the button is released (i.e. the touch/click that pressed the button goes away).

text

Chip text.

text is an StringProperty and defaults to ‘’.

icon

Chip icon.

icon is an StringProperty and defaults to ‘checkbox-blank-circle’.

color

Chip color in rgba format.

color is an ColorProperty and defaults to None.

text_color

Chip’s text color in rgba format.

text_color is an ColorProperty and defaults to None.

icon_color

Chip’s icon color in rgba format.

icon_color is an ColorProperty and defaults to None.

check

If True, a checkmark is added to the left when touch to the chip.

check is an BooleanProperty and defaults to False.

radius

Corner radius values.

radius is an ListProperty and defaults to ‘[dp(12),]’.

selected_chip_color

The color of the chip that is currently selected in rgba format.

selected_chip_color is an ColorProperty and defaults to None.

set_color(self, interval)
on_icon(self, instance, value)
on_touch_down(self, touch)

Receive a touch down event.

Parameters
touch: MotionEvent class

Touch received. The touch is in parent coordinates. See relativelayout for a discussion on coordinate systems.

Returns

bool If True, the dispatching of the touch event will stop. If False, the event will continue to be dispatched to the rest of the widget tree.

class kivymd.uix.chip.MDChooseChip(**kwargs)

Stack layout class. See module documentation for more information.

add_widget(self, widget, index=0, canvas=None)

Add a new widget as a child of this widget.

Parameters
widget: Widget

Widget to add to our list of children.

index: int, defaults to 0

Index to insert the widget in the list. Notice that the default of 0 means the widget is inserted at the beginning of the list and will thus be drawn on top of other sibling widgets. For a full discussion of the index and widget hierarchy, please see the Widgets Programming Guide.

New in version 1.0.5.

canvas: str, defaults to None

Canvas to add widget’s canvas to. Can be ‘before’, ‘after’ or None for the default canvas.

New in version 1.9.0.

>>> from kivy.uix.button import Button
>>> from kivy.uix.slider import Slider
>>> root = Widget()
>>> root.add_widget(Button())
>>> slider = Slider()
>>> root.add_widget(slider)