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

Function control

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

Source from the content-addressed store, hash-verified

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