Selector-Based Layout Rules
As opposed to Object-Specific Layout Rules, selector-based rules can apply to more than one object. To select which objects a rule will apply to, we use the concept of selectors (heavily inspired by the CSS Selector Syntax). If you're coming from other EDA tools, selectors are similar to queries. It's a syntax that allows you to select specific matching objects.
Adding a selector-based rule
To create a ruleset:
- Navigate to the PCB editor of your project
- Select the "Rules" tab in panel on the left of the screen
- Choose the "New Ruleset" button and new item will appear underneath the project rules titled "New Ruleset"

Once you select that new ruleset, you will notice that a new panel appears on the right side of the canvas. This is where you will determine the selectors that determine what objects are affected and the rules that will apply to the objects
- Select "Edit" under the "Layout Rules" section of the right-hand panel and then click "Add".
- Add the rules that you wish to define in your currently selected ruleset.
- Select the value for each of the added rules.
Highlighting
To help you understand what you're selecting, Flux will highlight objects that match your selector. Once you finish typing, bounding boxes will appear on the canvas and in the Objects list.

Case Sensitive
Selectors are case sensitive. For example, in the above screenshot, only trace
will select all traces for you, but Trace
will not select anything.
Selector types
Type Selector
Syntax | What it selects |
---|---|
objectname | Selects all objects that have the specified object type. |
Example
This PCB project has two resistors and a trace. Since the object type of the resistors is element, the element
selector is selecting them and applying a rule, which is rotating them. The trace, however, is unaffected, since it isn't an element type.

You must use specific object types, such as layout
or trace
. See a full list of all the object type.
Designator Selector
Syntax | What it selects |
---|---|
#idname | Selects an object based on the value of its designator. There should be only one object with a given designator in a project. This is similar to the CSS #id Selector. |
Example: #R2
will match the object that has the designator "R2".

Note: Flux won't prevent you from having duplicate designators in your project. Duplicate designators will make it harder to select a specific object. For example, if both of these resistors were designated "R2", both of them would be selected by #R2. Avoid this by using unique designators.
Property Selector
Selects all objects that have the specified property.
This is a powerful kind of selector with different operations which allow you to customize selections.
- Direct Select
- Exact Value Match
- Partial Match - One word
- Partial Match - Whole word or followed by a hyphen
- Partial Match - Prefix
- Partial Match - Suffix
- Partial Match - Occurrence
- Configure case sensitivity for matching
1. Direct Select
Syntax | What is selects |
---|---|
[prop] | Selects objects that have a property named prop . |
Details: Only properties with set values will be selected. For example, if you had a resistor with property "Resistance" but with an empty value, then [Resistance]
wont select the resistor for you.

To select properties with multiple words, omit the spaces between the words. For example, to select objects that have set values for "Manufacturer Name" property, type [ManufacturerName]
.

2. Exact Value Match
Syntax | What it selects |
---|---|
[prop="value"] | Selects objects that have a property named prop whose value is exactly value . |
Example
We have two resistors from different manufacturers and we only want to select one.
- R1 with "Manufacturer Name" = "Microchip"
- R2 with "Manufacturer Name" = "Texas Instruments"
Typing [ManufacturerName="Texas Instruments"]
will select R2.

If the value has multiple words, you must wrap it inside a double quote. However, if the value is a single word (i.e. with no space in between), you can omit the double quotes. For example, to select R1 in the above example, both selectors work:
[ManufacturerName="Microchip"]
[ManufacturerName=Microchip]
- However, it is always recommended to wrap your value with double quotes, just so that the value is easily distinguished from the the case sensitive/insensitive indicator (see the last two topics of this section below)
3. Partial Match - One word
Syntax | What it selects |
---|---|
[prop~="value"] | Selects objects that have a property named prop whose value contains value . |
Example
Here we set up R1 and R2 as following:
- R1 with "Manufacturer Name" = "Microchip"
- R2 with "Manufacturer Name" = "Texas Instruments"
Typing [ManufacturerName~="Texas"]
will select R2 because "Texas Instruments" contains the word "Texas".

Important Notes:
- You must wrap the value in double quotes. In other words,
[ManufacturerName~=Texas]
might not always work. - This syntax only matches complete words. So an incomplete word like
ManufacturerName~="Texa"]
won't select anything because "Texas Instruments" doesn't contain word "Texa".
4. Partial Match - Whole word or followed by a hyphen
Syntax | What it selects |
---|---|
[prop|="value"] | Selects objects that have a property named prop whose value can be exactly value or can begin with value immediately followed by a hyphen. It is often used for language subcode matches. |
Example
Here we set up R1 and R2 as following:
- R1 with "Manufacturer Name" = "Microchip", and no other properties
- R2 with
- "Manufacturer Name" = "Texas Instruments"
- "Manufacturer Part Number" = "N-123"
- "Datasheet URL" = "Texas" - just for demoing purpose
[ManufacturerName|="Texas"]
will NOT select R2, because the value of "Manufacturer Name" is not "Texas"

[ManufacturerPartNumber|="N"]
will select R2.

[DatasheetURL|="Texas"]
will select R2.

Important Notes:
- You must wrap the value in double quotes. In other words,
[DatasheetURL|=Texas]
might not always work. - The
value
has to be a whole word, either alone, or followed by a hyphen (-).
5. Partial Match - Prefix
Syntax | What it selects |
---|---|
[prop^="value"] | Selects objects that have a property named prop whose value is prefixed (preceded) by value . |
Example
Here we set up R1 and R2 as following:
- R1 with "Manufacturer Name" = "Microchip"
- R2 with "Manufacturer Name" = "Texas Instruments"
Then, [ManufacturerName^="Tex"]
will select R2.

Important Notes
- Since this is a prefix match, it is not required to match the whole word. Any
value
that begins with the specified prefix will match. - Spaces can be included in the prefix. For example,
[ManufacturerName^="Texas "]
will also select R2 in this case.
6. Partial Match - Suffix
Syntax | What this selects |
---|---|
[prop$="value"] | Selects objects with a property named prop whose value is suffixed (followed) by value . |
Example
Here we set up R1 and R2 as following:
- R1 with "Manufacturer Name" = "Microchip"
- R2 with "Manufacturer Name" = "Texas Instruments"
Then, [ManufacturerName$="ments"]
will select R2.

Since this is a suffix match, it is not required to match the whole word. Any value
ending with the specified suffix will match.
7. Partial Match - Occurrence
Syntax | What this selects |
---|---|
[prop*="value"] | Selects objects with a property named prop whose value contains at least one occurrence of value within the string. |
Example
Here we set up R1 and R2 as following:
- R1 with "Manufacturer Name" = "Microchip"
- R2 with "Manufacturer Name" = "Texas Instruments"
Then, [ManufacturerName*="c"]
will select R1, because "Microchip" contains the letter "c".

Details
- Since this is an occurrence match, it is not required to match the whole word. Any
value
containing the specified string will match. - Any length of
value
may be used. Here, we are just using "i" as an example.
8. Configure case sensitivity for matching
Syntax | What this selects |
---|---|
[prop operator value i] | Adding an i (or I ) before the closing bracket causes value to be compared case-insensitively (for characters within the ASCII range). |
[prop operator value s] | Adding an s (or S ) before the closing bracket causes value to be compared case-sensitively (for characters within the ASCII range). |
Explanation
When performing a value match, by default, we respect case sensitive when match values. For example, let's say we set up R1 and R2 as following:
- R1 with "Manufacturer Name" = "Microchip"
- R2 with "Manufacturer Name" = "Texas Instruments"
[ManufacturerName*="i"]
will only match R1 but not R2. Because even though R2 has an upper case letter "I", we won't treat it as a match. And because this is the default setting, [ManufacturerName*="i"]
is equivalent to [ManufacturerName*="i"s]
.

Now if we put an "i" at the end - [ManufacturerName*="i"i]
will select both R1 and R2.

Grouping Selectors
Selector List
Syntax | What this selects |
---|---|
A, B | The , selector is a grouping method that selects all the matching objects. |
Example
Here we set up R1 and R2 as following:
- R1 with "Manufacturer Name" = "Microchip"
- R2 with "Manufacturer Name" = "Texas Instruments"
#R1, [ManufacturerName="Texas Instruments"]
will select both R1 and R2.

Combinators
Descendant Combinator
Syntax | What this selects |
---|---|
A B | The " " (space) combinator selects objects that are descendants of the first object. |
Example
In the following example we have three pads on a board, but one of them is under "Components" (which is a container
object), and the other two are under the Layout
object. Then we have two resistors under "Components", and each resistor has two pads in their sub-layouts.
Typing #R1 pad
will only select the pad
under resistor R1
, because it is saying: get me all pads that are descendants of component with Designator "R1",.

Please note that this selector is selecting descendants of the first object. In other words, with the above example, layout pad
will select you all three pads because all three pads are descendants of Layout
node

Child Combinator
Syntax | What this selects |
---|---|
A > B | The > combinator selects objects that are direct children of the first object. |
Example
Let's keep using the setup from Descendant Combinator above.
The selector layout > pad
will only select the two pads that are directly under the Layout
node for you. Because it is looking for direct children.

Basic Examples
Below is a series of basic examples that involve using selector syntax. See further below for more advanced examples that may involve multiple syntax points.
Setting Text Size for Selected Capacitors
Selector input: #C2 text, #C4 text, C6 text
Applied rules: Font Size
- This sets the text size for components C2, C4, and C6
- The space between C2 and text signifies the children of the C2 elements
- The comma acts as a logical addition or inclusive disjunction, essentially adding more elements to select
Objects that can be selected in this method include: net, trace, pad, text
Setting Trace Width for All Nets
Selector input: net
Applied rules: Trace Width
- This selects all net objects in the layout and applies the Trace Width Rule
Setting Font Size of Specific Text
Selector input: [name*=VALUE]
Applied rules: Font Size
- This finds all objects with a property called name that contains the word VALUE
- These objects were previously added this property by the designer
Setting Keep Out Clearances for a Component’s Pads
Selector input: #C1 pad
Applied rules: Keep Out, Keep Out Minimum
- This sets the keep out values only for the pads of C1
- C1 was selected using the #, all of its children were selected using the space, and then just the pads was selected using the pad input
Selecting Based off Components’ Other Properties
Selector input: [Manufacturer Name*=Hirose]
- This will select all component’s that have a Manufacturer Name property, that contains the text Hirose

Setting Trace Width and Keep Out for Microstrip Traces
Selector input: #RF1,#RF2
Applied rules: Keep Out, Trace Width
- Nets RF1 and RF2 were specifically named as they are microstrip traces and need special care
- Another method: adding an RF property set to TRUE for necessary components, then create a selector rule with selector input:
[RF*=TRUE]

Setting Custom Solder Mask for all Component-Unrelated Pads
Selector input: layout>pad
- This selector input selects all direct children of the layout that are pads. Because pads that are part of components are children of the components, which in turn are children of the layout, they are NOT selected. Rather, going one step down the hierarchy from the layout root, all designer-added additional pads will be selected, NOT related to components.
- Component pads are children of the components themselves
- If instead was a space between
layout
andpad
then all pads in the layout (regardless of location in the hierarchy) will be selected.
Advanced Examples
Setting Custom Size of Text for Specific Manufacturers
Selector input: [ManufacturerName$="ments"] text
Applied rules: Font size
- This will select the text size of all components with a manufacturer name that contains "ments" .