In mobile UI design, a Chip is a compact element displaying attributes, input, or actions.
If you want to change the height of the Chip later on after initializing, pass the height argument.
Here are the methods available for Chips Component
Examples
Example - Chips
class Main extends App
{
onStart()
{
this.main = ui.addLayout("main", "Linear", "VCenter,FillXY")
this.main.setChildMargins(0, 0.025, 0, 0.025)
this.chip1 = ui.addChip(this.main, "Basic Chip")
this.chip1.setOnTouch( this.onTouch )
this.chip2 = ui.addChip(this.main, "Small Primary Chip", "Primary,Small")
this.chip2.setOnTouch( this.onTouch )
this.chip3 = ui.addChip(this.main, "Secondary Chip", "Secondary,Touchable")
this.chip2.setOnTouch( this.onTouch )
}
onTouch()
{
ui.showPopup( "You touched the chip!" )
}
}
from hybrid import ui
def OnStart():
main = ui.addLayout("main", "Linear", "VCenter,FillXY")
main.setChildMargins(0, 0.025, 0, 0.025)
chip1 = ui.addChip(main, "Basic Chip")
chip1.setOnTouch(onTouch)
chip2 = ui.addChip(main, "Small Primary Chip", "Primary,Small")
chip2.setOnTouch(onTouch)
chip3 = ui.addChip(main, "Secondary Chip", "Secondary,Touchable")
chip3.setOnTouch(onTouch)
def onTouch(event):
ui.showPopup("You touched the chip!")
sample = Main()
sample.start()
Example - Deletable chip
class Main extends App
{
onStart()
{
this.main = ui.addLayout("main", "Linear", "VCenter,FillXY")
this.chip = ui.addChip(this.main, 'Deletable', 'Secondary,Touchable')
this.chip.setOnDelete( this.onDelete )
}
onDelete()
{
ui.showPopup( "Chip is deleted!" )
}
}
from hybrid import ui
def OnStart():
main = ui.addLayout("main", "Linear", "VCenter,FillXY")
chip = ui.addChip(main, 'Deletable', 'Secondary,Touchable')
chip.setOnDelete(onDelete)
def onDelete():
ui.showPopup("Chip is deleted!")
sample = Main()
sample.start()
Example - Custom styles
class Main extends App
{
onStart()
{
this.main = ui.addLayout("main", "Linear", "VCenter,FillXY")
this.chip = ui.addChip(this.main, "Shopping Cart")
this.chip.icon = "shopping_cart"
this.chip.iconColor = "#673ab7"
this.chip.textSize = 14
}
}
from hybrid import ui
def OnStart():
main = ui.addLayout("main", "Linear", "VCenter,FillXY")
chip = ui.addChip(main, "Shopping Cart")
chip.icon = "shopping_cart"
chip.iconColor = "#673ab7"
chip.textSize = 14
sample = Main()
sample.start()
Example - Avatar
class Main extends App
{
onStart()
{
this.main = ui.addLayout("main", "Linear", "VCenter,FillXY")
this.chip = ui.addChip(this.main, "Character Avatar")
this.chip.avatar = "https://upload.wikimedia.org/wikipedia/commons/thumb/9/90/Hapus_Mango.jpg/220px-Hapus_Mango.jpg"
}
}
from hybrid import ui
def OnStart():
main = ui.addLayout("main", "Linear", "VCenter,FillXY")
chip = ui.addChip(main, "Character Avatar")
chip.avatar = "https://upload.wikimedia.org/wikipedia/commons/thumb/9/90/Hapus_Mango.jpg/220px-Hapus_Mango.jpg"
sample = Main()
sample.start()
Properties
The following properties are available on the Chip object:
Methods
The following methods are available on the Chip object:
Boolean: Can be `true` or `false`
Number: Fraction of the parent width `[0-1]`
Number: Fraction of the parent height `[0-1]`
Number: The time in milliseconds.
Number: The z-index. A negative value behaves like `sendBackward` method.
Number: The z-index. A positve value behaves like `bringForward` method.
Number: Border-left thickness in pixels.
Number: Border-top thickness in pixels.
Number: Border-right thickness in pixels.
Number: Border-bottom thickness in pixels.
Number: Top-left corner radius.
Number: Top-right corner radius.
Number: Bottom-left corner radius.
Number: Bottom-right corner radius.
Number: Left margin. You can also pass string e.g. `12rem`
Number: Top margin. You can also pass string e.g. `12rem`
Number: Right margin. You can also pass string e.g. `12rem`
Number: Bottom margin. You can also pass string e.g. `12rem`
Number: Fraction of the component width.
Number: Fraction of the component height. [0-1]
Number: Fraction of the component width. [0-1]
Number: Fraction of the parent width. [0-1]
Number: Fraction of the parent height. [0-1]
Number: The x-scale of the component.Values less than `0` is smaller than the normal. While values greater than `1` is greater than the normal.
Number: The y-scale of the component. Values less than `1` is smaller than the normal. While vaues greater than `1` is greater than the normal.
String: “The text on the chip.”
String: “A comma separated option.
Theme Color: `Primary`”, “ `Secondary`”, “ `Default`
Size: `Small`”, “ `Medium`
Variant: `Outlined`”, “ `Default`
Util: `Touchable`”
String: “The type of animation. Here are the available values
`bounce`”, “ `flash`”, “ `pulse`”, “ `rubberBand`”, “ `shakeX`”, “ `shakeY`”, “ `headShake`”, “ `swing`”, “ `tada`”, “ `wobble`”, “ `jello`”, “ `heartBeat`”, “
Back Entrances: `backInDown`”, “ `backInLeft`”, “ `backInRight`”, “ `backInUp`
Back Exits: `backOutDown`”, “ `backOutLeft`”, “ `backOutRight`”, “ `backOutUp`
Bouncing Entrances: `bounceIn`”, “ `bounceInDown`”, “ `bounceInLeft`”, “ `bounceInRight`”, “ `bounceInUp`
Bouncing exits: `bounceOut`”, “ `bounceOutDown`”, “ `bounceOutLeft`”, “ `bounceOutRight`”, “ `bounceOutUp`
Fading entrances: `fadeIn`”, “ `fadeInDown`”, “ `fadeInDownBig`”, “ `fadeInLeft`”, “ `fadeInLeftBig`”, “ `fadeInRight`”, “ `fadeInRightBig`”, “ `fadeInUp`”, “ `fadeInUpBig`”, “ `fadeInTopLeft`”, “ `fadeInTopRight`”, “ `fadeInBottomLeft`”, “ `fadeInBottomRight`
Fading exits: `fadeOut`”, “ `fadeOutDown`”, “ `fadeOutDownBig`”, “ `fadeOutLeft`”, “ `fadeOutLeftBig`”, “ `fadeOutRight`”, “ `fadeOutRightBig`”, “ `fadeOutUp`”, “ `fadeOutUpBig`”, “ `fadeOutTopLeft`”, “ `fadeOutTopRight`”, “ `fadeOutBottomRight`”, “ `fadeOutBottomLeft`
Flippers: `flip`”, “ `flipInX`”, “ `flipInY`”, “ `flipOutX`”, “ `flipOutY`
Lightspeed: `lightSpeedInRight`”, “ `lightSpeedInLeft`”, “ `lightSpeedOutRight`”, “ `lightSpeedOutLeft`
Rotating Entrances: `rotateIn`”, “ `rotateInDownLeft`”, “ `rotateInDownRight`”, “ `rotateInUpLeft`”, “ `rotateInUpRight`
Rotating Exits: `rotateOut`”, “ `rotateOutDownLeft`”, “ `rotateOutDownRight`”, “ `rotateOutUpLeft`”, “ `rotateOutUpRight`
Specials: `hinge`”, “ `jackInTheBox`”, “ `rollIn`”, “ `rollOut`
Zooming Entrances: `zoomIn`”, “ `zoomInDown`”, “ `zoomInLeft`”, “ `zoomInRight`”, “ `zoomInUp`
Zooming Exits: `zoomOut`”, “ `zoomOutDown`”, “ `zoomOutLeft`”, “ `zoomOutRight`”, “ `zoomOutUp`
Sliding Entrances: `slideInDown`”, “ `slideInLeft`”, “ `slideInRight`”, “ `slideInUp`
Sliding Exits: `slideOutDown`”, “ `slideOutLeft`”, “ `slideOutRight`”, “ `slideOutUp`”
String: “The mode of the measurements. Values can be `px` or `%`”
String: “Border color in hexadecimal format `#rrggbb`.”
String: “Border-styles. Values can be `dotted`”, “ `dashed`”, “ `solid`”, “ `double`”, “ `groove`”, “ `ridge`”, “ `inset` and `outset`. Default is `solid`”
String: “Unit. Values are `px` `rem` or `%`.”
String: “Unit of measurement.
`rem` for root em.
`px` for pixels
`%` relative to its parent dimension.
`v` relative to viewport dimension.”
String: “Unit of measurement.
`rem` for root em.
`px` for pixels
`%` relative to its parent dimensions
`v` relative to viewport dimensions.”
String: “Unit of measurment. Can be "px"”, “ "rem"”, “ "%"”, “ "v" for viewport width/height or any css supported unit.”
Object: The parent layout where to add the Chip.
Object: The pointer event object.
Object: The position of the touch event.
function()
chp.absHeight
Returns the absolute height of the control in pixels.
chp.absLeft
Returns the absolute distance of the control from the left in pixels.
chp.absTop
Returns the absolute distance of the control from the top in pixels.
chp.absWidth
Returns the absolute width of the control in pixels.
chp.animate
Animate the component.
chp.avatar
Sets or returns the avatar. Can be image or a single character.
chp.backColor
A hexadecimal color of the form #rrggbb
chp.backImage
The path to your image file.
chp.border
Sets or returns the border thickness in pixels.
chp.borderColor
Sets or returns the border color. Color is in hexadecimal form #rrggbb
chp.borderStyle
Sets or returns the border style. Values can be dotted, dashed, solid, double, groove, ridge, inset and outset. Default is solid.
chp.bringForward
Bring this component forward by a given z-index.
chp.color
Sets or returns the theme color of the chip. Values can be Default Primary Secondary
chp.cornerRadius
Sets or returns the corner radius in pixels.
chp.deleteIcon
Sets or returns the delete icon.
chp.destroy
Destroy the component.
chp.disabled
Sets or returns the disabled state of the control.
chp.el
Returns the html container element for the control.
chp.elStyle
Sets the style of the html container element.
chp.enabled
Returns whether the chip is enabled or disabled.
chp.fontFile
Sets or returns the relative path to the font-family use.
chp.getPosition
Returns the position of the component. The return object is of the form {left, top, right, bottom}
chp.gone
Destroy the component.
chp.height
Sets or returns the height of the control as a fraction of the parent control.
chp.hide
Hide the component.
chp.icon
Sets or returns the material icon font if icon is provided.
chp.iconColor
Sets or returns the icon color in hexadecimal format.
chp.iconSize
Sets or returns the font-size of the icon in css font-size format. You can pass string values to be more specific such as 12px 1.5rem.
chp.isVisible
Returns whether the control is visible or not.
chp.left
Returns the distance of the control from the left.
chp.margins
Sets or returns the margin of the control. Works on controls with Linear parent only. You can also pass a number to set equal margins for all sides.
chp.opacity
Sets or returns the opacity of the control.
chp.options
Sets or returns the options of the control.
chp.padding
Sets or returns the padding of the control. You can also pass a number to set equal padding for all sides.
chp.parent
Returns the parent layout control.
chp.position
Returns the position of the control. The returned object has left top right and bottom props.
chp.rotation
Sets or returns the angle of rotation in degrees.
chp.sendBackward
Bring this component backward by a given z-index.
chp.setBorder
Sets the border line for the component container.
chp.setCornerRadius
Sets the corner radius of the chip.
chp.setMargins
Sets the margin of the component.
chp.setOnContextMenu
Adds a callback function on right click.
chp.setOnDelete
Sets a callback function when the chip is deleted. This will automatically add a delete icon to the chip.
chp.setOnTouch
Adds a callback handler when the chip is touch.
chp.setPadding
Sets the padding of the component's container.
chp.setPosition
Sets the position of the component relative to its parent dimensions.
chp.setScale
Sets the x and y scaling of the component. This will ignore the positioning and flow of controls in the layout.
chp.setSize
Sets the size of the component.
chp.setTouchable
Sets the chip to clickable. This will add a pointer cursor into the chip when hovered.
chp.show
Show the component.
chp.sizeVariant
Sets or returns the size variant. Values can be small or medium
chp.text
Sets or returns the text of the chip.
chp.textColor
Sets or returns the color of the text.
chp.textSize
Sets or returns the size of the text within the control.
chp.top
Returns the distance of the control from the top.
chp.type
Returns the type of the control.
chp.variant
Sets or returns the variant of the chip. Vaues can be Default or Outlined
chp.visibility
Sets or returns the visibility of the control.
chp.width
Sets or returns the width of the control as a fraction of the parent control.