@@ -85,30 +85,31 @@ Usage: svgr [options] <file>
85
85
86
86
Options:
87
87
88
- -V, --version output the version number
89
- -d, --out-dir <dirname> output files into a directory
90
- --no-svgo disable SVGO (default: true)
91
- --no-prettier disable Prettier (default: true)
92
- --template <file> specify a custom template to use
93
88
--ext <ext> specify a custom file extension to use (default: "js")
94
- --no-expand-props disable props expanding (default: true)
95
- --ref add svgRef prop to svg
89
+ --help, -h output usage information
96
90
--icon use "1em" as width and height
97
- --no-view-box remove viewBox (default: true)
98
- --native add react-native support with react-native-svg
99
- --replace-attr-value [old=new] replace an attribute value
100
- -p, --precision <value> set the number of digits in the fractional part (svgo)
101
91
--ids keep ids within the svg (svgo)
92
+ --jsx-bracket-same-line put the > of a multi-line JSX element at the end of the last line instead of being alone on the next line (prettier)
102
93
--keep-useless-defs keep elements of <defs> without id (svgo)
103
- --no-title remove title tag (svgo) (default: true)
104
- --tab-width specify the number of spaces by indentation-level (prettier)
105
- --use-tabs indent lines with tabs instead of spaces (prettier)
94
+ --native add react-native support with react-native-svg
95
+ --no-bracket-spacing print spaces between brackets in object literals (prettier) (default: true)
96
+ --no-dimensions remove width and height from root SVG tag (default: false)
97
+ --no-expand-props disable props expanding (default: true)
98
+ --no-prettier disable Prettier (default: true)
106
99
--no-semi remove semi-colons (prettier) (default: true)
100
+ --no-svgo disable SVGO (default: true)
101
+ --no-title remove title tag (svgo) (default: true)
102
+ --no-view-box remove viewBox (default: true)
103
+ --out-dir, -d <dirname> output files into a directory
104
+ --precision, -p <value> set the number of digits in the fractional part (svgo)
105
+ --ref add svgRef prop to svg
106
+ --replace-attr-value [old=new] replace an attribute value
107
107
--single-quote use single-quotes instead of double-quotes (prettier)
108
+ --tab-width specify the number of spaces by indentation-level (prettier)
109
+ --template <file> specify a custom template to use
108
110
--trailing-comma <none|es5|all> print trailing commas wherever possible when multi-line (prettier)
109
- --no-bracket-spacing print spaces between brackets in object literals (prettier) (default: true)
110
- --jsx-bracket-same-line put the > of a multi-line JSX element at the end of the last line instead of being alone on the next line (prettier)
111
- -h, --help output usage information
111
+ --use-tabs indent lines with tabs instead of spaces (prettier)
112
+ --version, -V output the version number
112
113
113
114
Examples:
114
115
svgr --replace-attr-value "#fff=currentColor" icon.svg
@@ -317,33 +318,6 @@ By default, `svgr/webpack` includes a `babel-loader` with [optimized configurati
317
318
SVGR ships with a handful of customizable options, usable in both the CLI and
318
319
API.
319
320
320
- ### SVGO
321
-
322
- Use [ SVGO] ( https://github.com/svg/svgo/ ) to optimize SVG code before
323
- transforming it into a component.
324
-
325
- | Default | CLI Override | API Override |
326
- | ------- | ------------ | -------------- |
327
- | ` true ` | ` --no-svgo ` | ` svgo: <bool> ` |
328
-
329
- ### Prettier
330
-
331
- Use [ Prettier] ( https://github.com/prettier/prettier ) to format JavaScript code
332
- output.
333
-
334
- | Default | CLI Override | API Override |
335
- | ------- | --------------- | ------------------ |
336
- | ` true ` | ` --no-prettier ` | ` prettier: <bool> ` |
337
-
338
- ### Template
339
-
340
- Specify a template file (CLI) or a template function (API) to use. For an
341
- example of template, see [ the default one] ( src/transforms/wrapIntoComponent.js ) .
342
-
343
- | Default | CLI Override | API Override |
344
- | ---------------------------------------------------------- | ------------ | ------------------ |
345
- | [ ` wrapIntoComponent ` ] ( src/transforms/wrapIntoComponent.js ) | ` --template ` | ` template: <func> ` |
346
-
347
321
### File extension
348
322
349
323
Specify a custom extension for generated files.
@@ -352,14 +326,6 @@ Specify a custom extension for generated files.
352
326
| ------- | ------------ | --------------- |
353
327
| ` "js" ` | ` --ext ` | ` ext: <string> ` |
354
328
355
- ### Expand props
356
-
357
- All properties given to component will be forwarded on SVG tag.
358
-
359
- | Default | CLI Override | API Override |
360
- | ------- | ------------------- | --------------------- |
361
- | ` true ` | ` --no-expand-props ` | ` expandProps: <bool> ` |
362
-
363
329
### Icon
364
330
365
331
Replace SVG "width" and "height" value by "1em" in order to make SVG size
@@ -369,6 +335,36 @@ inherits from text size. Also remove title.
369
335
| ------- | ------------ | -------------- |
370
336
| ` false ` | ` --icon ` | ` icon: <bool> ` |
371
337
338
+ ### Ids
339
+
340
+ Setting this to ` true ` will keep ids. It can be useful to target specific ids
341
+ using CSS or third party library (eg:
342
+ [ react-mutate-icon] ( https://github.com/lifeiscontent/react-mutate-icon ) ).
343
+
344
+ | Default | CLI Override | API Override |
345
+ | ------- | ------------ | ------------- |
346
+ | ` false ` | ` --ids ` | ` ids: <bool> ` |
347
+
348
+ ### JSX Brackets
349
+
350
+ Put the ` > ` of a multi-line JSX element at the end of the last line instead of
351
+ being alone on the next line (does not apply to self closing elements). See
352
+ [ Prettier] ( https://github.com/prettier/prettier/blob/master/README.md#jsx-brackets ) .
353
+
354
+ | Default | CLI Override | API Override |
355
+ | ------- | ------------------------- | ---------------------------- |
356
+ | ` false ` | ` --jsx-bracket-same-line ` | ` jsxBracketSameLine: <bool> ` |
357
+
358
+
359
+ ### Useless Defs
360
+
361
+ Keep elements of ` <defs> ` without ` id ` . It also keep unused symbols. See
362
+ [ SVGO ` removeUselessDefs ` plugin] ( https://github.com/svg/svgo ) .
363
+
364
+ | Default | CLI Override | API Override |
365
+ | ------- | --------------------- | ------------------------- |
366
+ | ` false ` | ` --keep-useless-defs ` | ` keepUselessDefs: <bool> ` |
367
+
372
368
### Native
373
369
374
370
Modify all SVG nodes with uppercase and use a specific template with
@@ -378,58 +374,58 @@ react-native-svg imports. **All unsupported nodes will be removed.**
378
374
| ------- | ------------ | ---------------- |
379
375
| ` false ` | ` --native ` | ` native: <bool> ` |
380
376
381
- ### ViewBox
382
377
383
- Setting this to ` false ` will remove the viewBox property.
378
+ ### Bracket Spacing
384
379
385
- | Default | CLI Override | API Override |
386
- | ------- | --------------- | ----------------- |
387
- | ` true ` | ` --no-view-box ` | ` viewBox: <bool> ` |
380
+ Print spaces between brackets in object literals. See
381
+ [ Prettier] ( https://github.com/prettier/prettier/blob/master/README.md#bracket-spacing ) .
388
382
389
- ### Ids
383
+ | Default | CLI Override | API Override |
384
+ | ------- | ---------------------- | ------------------------ |
385
+ | ` true ` | ` --no-bracket-spacing ` | ` bracketSpacing: <bool> ` |
390
386
391
- Setting this to ` true ` will keep ids. It can be useful to target specific ids
392
- using CSS or third party library (eg:
393
- [ react-mutate-icon] ( https://github.com/lifeiscontent/react-mutate-icon ) ).
387
+ ### Dimensions
394
388
395
- | Default | CLI Override | API Override |
396
- | ------- | ------------ | ------------- |
397
- | ` false ` | ` --ids ` | ` ids: <bool> ` |
389
+ Remove width and height from root SVG tag.
398
390
399
- ### Ref
391
+ | Default | CLI Override | API Override |
392
+ | ------- | ----------------- | -------------------- |
393
+ | ` false ` | ` --no-dimensions ` | ` dimensions: <bool> ` |
400
394
401
- Setting this to ` true ` will allow you to hook into the ref of the svg components that are created by exposing a ` svgRef ` prop
395
+ ### Expand props
402
396
403
- | Default | CLI Override | API Override |
404
- | ------- | ------------ | ------------- |
405
- | ` false ` | ` --ref ` | ` ref: <bool> ` |
397
+ All properties given to component will be forwarded on SVG tag.
406
398
407
- ### Replace attribute value
399
+ | Default | CLI Override | API Override |
400
+ | ------- | ------------------- | --------------------- |
401
+ | ` true ` | ` --no-expand-props ` | ` expandProps: <bool> ` |
408
402
409
- Replace an attribute value by an other. The main usage of this option is to
410
- change an icon color to "currentColor" in order to inherit from text color.
403
+ ### Prettier
411
404
412
- | Default | CLI Override | API Override |
413
- | ------- | -------------------------------- | ------------------------------- |
414
- | ` [] ` | ` --replace-attr-value <old=new> ` | ` replaceAttrValues: <string[]> ` |
405
+ Use [ Prettier] ( https://github.com/prettier/prettier ) to format JavaScript code
406
+ output.
415
407
416
- ### Precision
408
+ | Default | CLI Override | API Override |
409
+ | ------- | --------------- | ------------------ |
410
+ | ` true ` | ` --no-prettier ` | ` prettier: <bool> ` |
417
411
418
- Set number of digits in the fractional part. See
419
- [ SVGO] ( https://github.com/svg/svgo ) .
412
+ ### Semicolons
420
413
421
- | Default | CLI Override | API Override |
422
- | ------- | ------------------- | ------------------ |
423
- | ` 3 ` | ` --precision <int> ` | ` precision: <int> ` |
414
+ Print semicolons at the ends of statements. See
415
+ [ Prettier] ( https://github.com/prettier/prettier/blob/master/README.md#semicolons ) .
424
416
425
- ### Useless Defs
417
+ | Default | CLI Override | API Override |
418
+ | ------- | ------------ | -------------- |
419
+ | ` true ` | ` --no-semi ` | ` semi: <bool> ` |
426
420
427
- Keep elements of ` <defs> ` without ` id ` . It also keep unused symbols. See
428
- [ SVGO ` removeUselessDefs ` plugin] ( https://github.com/svg/svgo ) .
421
+ ### SVGO
429
422
430
- | Default | CLI Override | API Override |
431
- | ------- | --------------------- | ------------------------- |
432
- | ` false ` | ` --keep-useless-defs ` | ` keepUselessDefs: <bool> ` |
423
+ Use [ SVGO] ( https://github.com/svg/svgo/ ) to optimize SVG code before
424
+ transforming it into a component.
425
+
426
+ | Default | CLI Override | API Override |
427
+ | ------- | ------------ | -------------- |
428
+ | ` true ` | ` --no-svgo ` | ` svgo: <bool> ` |
433
429
434
430
### Title
435
431
@@ -440,32 +436,30 @@ Remove the title from SVG. See
440
436
| ------- | ------------ | --------------- |
441
437
| ` true ` | ` --no-title ` | ` title: <bool> ` |
442
438
443
- ### Tab Width
439
+ ### ViewBox
444
440
445
- Specify the number of spaces per indentation-level. See
446
- [ Prettier] ( https://github.com/prettier/prettier/blob/master/README.md#tab-width ) .
441
+ Setting this to ` false ` will remove the viewBox property.
447
442
448
- | Default | CLI Override | API Override |
449
- | ------- | ------------------- | ----------------- |
450
- | ` 2 ` | ` --tab-width <int> ` | ` tabWidth : <int >` |
443
+ | Default | CLI Override | API Override |
444
+ | ------- | --------------- | ----------------- |
445
+ | ` true ` | ` --no-view-box ` | ` viewBox : <bool >` |
451
446
452
- ### Tabs
447
+ ### Ref
453
448
454
- Indent lines with tabs instead of spaces. See
455
- [ Prettier] ( https://github.com/prettier/prettier/blob/master/README.md#tabs ) .
449
+ Setting this to ` true ` will allow you to hook into the ref of the svg components that are created by exposing a ` svgRef ` prop
456
450
457
- | Default | CLI Override | API Override |
458
- | ------- | ------------ | ----------------- |
459
- | ` false ` | ` --use-tabs ` | ` useTabs : <bool>` |
451
+ | Default | CLI Override | API Override |
452
+ | ------- | ------------ | ------------- |
453
+ | ` false ` | ` --ref ` | ` ref : <bool>` |
460
454
461
- ### Semicolons
455
+ ### Replace attribute value
462
456
463
- Print semicolons at the ends of statements. See
464
- [ Prettier ] ( https://github.com/prettier/prettier/blob/master/README.md#semicolons ) .
457
+ Replace an attribute value by an other. The main usage of this option is to
458
+ change an icon color to "currentColor" in order to inherit from text color .
465
459
466
- | Default | CLI Override | API Override |
467
- | ------- | ------------ | -------------- |
468
- | ` true ` | ` --no-semi ` | ` semi : <bool >` |
460
+ | Default | CLI Override | API Override |
461
+ | ------- | -------------------------------- | ----------------- -------------- |
462
+ | ` [] ` | ` --replace-attr-value <old=new> ` | ` replaceAttrValues : <string[] >` |
469
463
470
464
### Quotes
471
465
@@ -476,6 +470,24 @@ Use single quotes instead of double quotes. See
476
470
| ------- | ---------------- | --------------------- |
477
471
| ` false ` | ` --single-quote ` | ` singleQuote: <bool> ` |
478
472
473
+ ### Tab Width
474
+
475
+ Specify the number of spaces per indentation-level. See
476
+ [ Prettier] ( https://github.com/prettier/prettier/blob/master/README.md#tab-width ) .
477
+
478
+ | Default | CLI Override | API Override |
479
+ | ------- | ------------------- | ----------------- |
480
+ | ` 2 ` | ` --tab-width <int> ` | ` tabWidth: <int> ` |
481
+
482
+ ### Template
483
+
484
+ Specify a template file (CLI) or a template function (API) to use. For an
485
+ example of template, see [ the default one] ( src/transforms/wrapIntoComponent.js ) .
486
+
487
+ | Default | CLI Override | API Override |
488
+ | ---------------------------------------------------------- | ------------ | ------------------ |
489
+ | [ ` wrapIntoComponent ` ] ( src/transforms/wrapIntoComponent.js ) | ` --template ` | ` template: <func> ` |
490
+
479
491
### Trailing Commas
480
492
481
493
Print trailing commas wherever possible when multi-line. See
@@ -485,24 +497,31 @@ Print trailing commas wherever possible when multi-line. See
485
497
| -------- | ------------------------------------------------------ | ------------------------------------------------------ |
486
498
| ` "none" ` | <code >--trailing-comma <none| ; es5| ; all></code > | <code >trailingComma: "<none| ; es5| ; all>"</code > |
487
499
488
- ### Bracket Spacing
500
+ ### Tabs
489
501
490
- Print spaces between brackets in object literals . See
491
- [ Prettier] ( https://github.com/prettier/prettier/blob/master/README.md#bracket-spacing ) .
502
+ Indent lines with tabs instead of spaces . See
503
+ [ Prettier] ( https://github.com/prettier/prettier/blob/master/README.md#tabs ) .
492
504
493
- | Default | CLI Override | API Override |
494
- | ------- | ---------------------- | ------- ----------------- |
495
- | ` true ` | ` --no-bracket-spacing ` | ` bracketSpacing : <bool>` |
505
+ | Default | CLI Override | API Override |
506
+ | ------- | ------------ | ----------------- |
507
+ | ` false ` | ` --use-tabs ` | ` useTabs : <bool>` |
496
508
497
- ### JSX Brackets
509
+ ### Output Directory
498
510
499
- Put the ` > ` of a multi-line JSX element at the end of the last line instead of
500
- being alone on the next line (does not apply to self closing elements). See
501
- [ Prettier] ( https://github.com/prettier/prettier/blob/master/README.md#jsx-brackets ) .
511
+ Output files into a directory.
502
512
503
- | Default | CLI Override | API Override |
504
- | ------- | ------------------------- | ---------------------------- |
505
- | ` false ` | ` --jsx-bracket-same-line ` | ` jsxBracketSameLine: <bool> ` |
513
+ | Default | CLI Override | API Override |
514
+ | ----------- | --------------------- | ------------------- |
515
+ | ` undefined ` | ` --out-dir <dirname> ` | ` outDir: <dirname> ` |
516
+
517
+ ### Precision
518
+
519
+ Set number of digits in the fractional part. See
520
+ [ SVGO] ( https://github.com/svg/svgo ) .
521
+
522
+ | Default | CLI Override | API Override |
523
+ | ------- | ------------------- | ------------------ |
524
+ | ` 3 ` | ` --precision <int> ` | ` precision: <int> ` |
506
525
507
526
## Other projects
508
527
0 commit comments