MCPcopy Create free account
hub / github.com/adobe/react-spectrum / control

Function control

packages/@react-spectrum/s2/src/style-utils.ts:291–344  ·  view source on GitHub ↗
(options: ControlOptions)

Source from the content-addressed store, hash-verified

289 * The text can optionally wrap, aligning the icon with the first line of text.
290 */
291export function control(options: ControlOptions): ControlResult {
292 let paddingX = options.shape === 'pill' ? ('pill' as const) : ('edge-to-text' as const);
293 let result: ControlResult = {
294 font: controlFont(),
295 display: 'flex',
296 alignItems: 'center',
297 boxSizing: 'border-box',
298 paddingX: paddingX,
299 minWidth: controlSize()
300 };
301
302 if (options.shape === 'pill') {
303 result.borderRadius = 'pill';
304 } else {
305 Object.assign(result, controlBorderRadius());
306 }
307
308 if (options.icon) {
309 result.columnGap = 'text-to-visual';
310 result.paddingX = {
311 default: paddingX,
312 [iconOnly]: 0
313 };
314 result['--iconMargin'] = {
315 type: 'marginStart',
316 value: {
317 default: fontRelative(-2),
318 [iconOnly]: 0
319 }
320 };
321 }
322
323 if (options.wrap) {
324 result.minHeight = controlSize();
325
326 if (options.icon) {
327 result.paddingY = 0;
328 result['--labelPadding'] = {
329 type: 'paddingTop',
330 value: centerPadding()
331 };
332 result.alignItems = {
333 default: 'baseline',
334 [iconOnly]: 'center'
335 };
336 } else {
337 result.paddingY = centerPadding();
338 }
339 } else {
340 result.height = controlSize();
341 }
342
343 return result;
344}
345
346const allowedOverrides = [
347 'margin',

Callers 9

Button.tsxFile · 0.90
Menu.tsxFile · 0.90
ComboBox.tsxFile · 0.90
Badge.tsxFile · 0.90
Field.tsxFile · 0.90
Picker.tsxFile · 0.90
TagGroup.tsxFile · 0.90
ActionButton.tsxFile · 0.90

Calls 5

fontRelativeFunction · 0.90
controlFontFunction · 0.85
controlSizeFunction · 0.85
controlBorderRadiusFunction · 0.85
centerPaddingFunction · 0.85

Tested by

no test coverage detected