ui.Button.style

Renvoie le style ActiveDictionary du widget, qui peut être modifié pour mettre à jour les styles du widget.

Propriétés qui se comportent comme leurs équivalents CSS:

  - height, maxHeight, minHeight (par exemple, "100px")

  - width, maxWidth, minWidth (par exemple, "100px")

  - padding, margin (par exemple, "4px 4px 4px 4px" ou simplement "4px")

  - color, backgroundColor (par exemple, "red" ou "#FF0000")

  - border (par exemple, "1px solid black")

  - borderColor (par exemple, "red black blue #FF0000")

  - borderRadius (par exemple, "10px")

  - borderStyle (par exemple, "solid dashed none dotted")

  - borderWidth (par exemple, "1px 0px 1px 0px")

  - fontSize (par exemple, "24px")

  - fontStyle (par exemple, "italic")

  - fontWeight (par exemple, "bold" ou "100")

  - fontFamily (par exemple, "monospace" ou "serif")

  - textAlign (par exemple, "left" ou "center")

  - textDecoration (par exemple, "underline" ou "line-through")

  - whiteSpace (par exemple, "nowrap" ou "pre")

  - affiché (vrai ou faux)

Propriétés de mise en page personnalisées compatibles (voir la documentation ui.Panel.Layout):

  - stretch ('horizontal', 'vertical', 'both')

  - position ('top-right', 'top-center', 'top-left', 'bottom-right', ...)

UtilisationRenvoie
Button.style()ui.data.ActiveDictionary
ArgumentTypeDétails
ce: ui.widgetui.WidgetInstance ui.Widget.

Exemples

Éditeur de code (JavaScript)

// Define a UI widget and add it to the map.
var widget = ui.Button({label: 'A ui.Button', style: {width: '400px'}});
Map.add(widget);

// View the UI widget's style properties; an ActiveDictionary.
print(widget.style());

// ActiveDictionaries are mutable; set a style property.
widget.style().set('backgroundColor', 'lightgray');
print(widget.style());

// Define the UI widget's style ActiveDictionary as a variable.
var widgetStyle = widget.style();
print(widgetStyle);

// Set the UI widget's style properties from the ActiveDictionary variable.
widgetStyle.set({border: '5px solid darkgray'});
print(widgetStyle);