ui.Button.style

Restituisce il dizionario attivo dello stile del widget, che può essere modificato per aggiornare gli stili del widget.

Proprietà che si comportano come le loro controparti CSS:

  - height, maxHeight, minHeight (ad es. "100px")

  - width, maxWidth, minWidth (ad es. "100px")

  - padding, margin (ad es. "4px 4px 4px 4px" o semplicemente "4px")

  - color, backgroundColor (ad es. "red" o "#FF0000")

  - border (ad es. "1px solid black")

  - borderColor (ad es. "red black blue #FF0000")

  - borderRadius (ad es. "10px")

  - borderStyle (ad es. "solid dashed none dotted")

  - borderWidth (ad es. "1px 0px 1px 0px")

  - fontSize (ad es. "24px")

  - fontStyle (ad es. "italic")

  - fontWeight (ad es. "bold" o "100")

  - fontFamily (ad es. "monospace" o "serif")

  - textAlign (ad es. "left" o "center")

  - textDecoration (ad es. "underline" o "line-through")

  - whiteSpace (ad es. "nowrap" o "pre")

  - shown (true o false)

Proprietà di layout personalizzate supportate (vedi la documentazione di ui.Panel.Layout):

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

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

UtilizzoResi
Button.style()ui.data.ActiveDictionary
ArgomentoTipoDettagli
questo: ui.widgetui.WidgetL'istanza ui.Widget.

Esempi

Editor di codice (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);