# GraffitiStyle
Class Inherits GraffitiSuite.BaseObject
## Compatibility
### Framework API Version
| 1.0 | 2.0 |
| :---: | :---: |
| True | True |
### Web
| 32-Bit | 64-Bit |
| :---: | :---: |
| True | True |
## Enumerations
| Name | Value | Description |
| --- | :---: | --- |
| States | Default <br> Hover <br> Pressed <br> Visited <br> Active <br> Target <br> Focus <br> FocusWithin <br> FocusVisible <br> Enabled <br> Disabled | |
## Methods
| Name | Parameters | Return Type | Description |
| --- | :---: | :---: | --- |
| AddTo | controlSelector as String | (None) | Applies the GraffitiStyle's CSS class name to the specified control. |
| AddTo | controlObject as WebControl | (None) | Applies the GraffitiStyle's CSS class name to the specified control. |
| Destroy | (None) | (None) | |
| Operator_Add | style as GraffitiStyle | GraffitiStyle | Returns a new GraffitiStyle that combines the content of the current style and the style supplied in the parameter. |
| RemoveFrom | controlSelector as String | (None) | Removes the GraffitiStyle's CSS class name from the specified control. |
| RemoveFrom | controlObject as WebControl | (None) | Removes the GraffitiStyle's CSS class name from the specified control. |
## Shared Methods
| Name | Parameters | Return Type | Description |
| --- | :---: | :---: | --- |
| Create | inSession as WebSession <br> withName as String <br> withContent as String <br> withState as GraffitiStyle.States = GraffitiStyle.States.Default | GraffitiStyle | Creates a new instance of a GraffitiStyle object with the specified parameters. withName should be unique for each use case. If you wish to reuse a WebStyle you have previously created for the specified WebSession, you simply supply the same withName parameter. |
| DestroyInstance | Name as String <br> SessionID as String | (None) | Destroys a GraffitiStyle instance and removes its CSS from the browser's DOM. |
| DestroyInstance | inSession as WebSession <br> Name as String | (None) | Destroys a GraffitiStyle instance and removes its CSS from the browser's DOM. |
| GetInstance | Name as String <br> SessionID as String <br> State as GraffitiStyle.States = GraffitiStyle.States.Default | GraffitiStyle | Will return the specified style if it exists, or create a new instance matching the passed parameters. |
| GetInstance | inSession as WebSession <br> Name as String <br> State as GraffitiStyle.States = GraffitiStyle.States.Default | GraffitiStyle | Will return the specified style if it exists, or create a new instance matching the passed parameters. |
| GetInstanceData | Name as String <br> SessionID as String <br> state as States | Dictionary | |
## Properties
| Name | Type | Default Value | Description |
| --- | :---: | :---: | --- |
| Content | String | Nil | The CSS content of the GraffitiStyle instance. |
| IsClass | Boolean | Nil | When False, any arbitrary CSS selector may be passed in the Create method's withName parameter to modify any portion of the DOM, including pseudo-selectors. |
| Name | String | Nil | The class name of this object. This is what will be used in the browser, so be careful what names you choose as there is the potential for undesirable results. |
| State | States | Nil | The browser object state under which this GraffitiStyle is applied. For example, Hover. |
## Notes
### About BaseStyle Properties
All GraffitiSuite controls have a BaseStyle property, but it is unused in some cases. This property is meant to apply to the background of the control, but doesn’t make sense in all scenarios. Typically, those control parts that logically may require styles have Style* properties that can be modified with a GraffitiStyle.
If you see a control whose BaseStyle property does not have an effect and you believe it should, please open a support ticket.
### Ensuring Effects
Due to some instances where default CSS takes precedence over later defined styles (such as in GraffitiAccordion), you may need to add the !important attribute to your CSSvalues. For example:
```
Var titleStyle As GraffitiStyle = GraffitiStyle.Create( Session, "AccordionHeader", "background: rgb(0,255,0) !important" )
```
## Examples
### Applying a GraffitiStyle to a Default Xojo Control
```
var myPaginationStyle as GraffitiStyle = GraffitiStyle.Create( Session, "myPaginationStyle", "background:rgba(0, 0, 0, 0.2);color:#00f" )
myPaginationStyle.AddTo(WebPagination1)
```
### Applying a GraffitiStyle to a GraffitiSuite Control
All GraffitiSuite components have a BaseStyle property which can be used for applying GraffitiStyles.
```
var myGridStyle as GraffitiStyle = GraffitiStyle.Create( Session, "myGridStyle", "background:rgba(0, 0, 0, 0.2);color:#00f" )
GraffitiGrid1.BaseStyle = myGridStyle
```
### Applying a GraffitiStyle to part of a Default Xojo Control
```
var myPaginationStyleActive as GraffitiStyle = GraffitiStyle.Create( Session, "myPaginationStyleActive", "background:rgba(0, 0, 0, 0.2);color:#00f" )
myPaginationStyleActive.AddTo("#" + WebPagination1.ControlID + " li.page-item.active")
```
### Creating a New GraffitiStyle
```
var gridRowEven as GraffitiStyle = GraffitiStyle.Create( Session, "gridRowEven", "background:rgba(0, 0, 0, 0.2);color:#00f" )
```
### Retrieve an Instance of a WebStyle
```
var styleOne as GraffitiStyle = GraffitiStyle.GetInstance( "tabStyleOne", Session.Identifier, GraffitiStyle.States.Default )
```